Skip to content

Commit

Permalink
revert the destroy, and use s0undt3chs advise
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Phipps authored and s0undt3ch committed Oct 25, 2023
1 parent 841486c commit 38725e2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
11 changes: 6 additions & 5 deletions tests/pytests/functional/test_payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,18 @@ def test_destroy(sreq, echo_server):
"""
Test the __del__ capabilities
"""
# ensure we actually have an open socket and not just testing against
# no actual sockets created.
assert sreq.send("clear", "foo") == {"enc": "clear", "load": "foo"}
# ensure no exceptions when we go to destroy the sreq, since __del__
# swallows exceptions, we have to call destroy directly
assert sreq.send("clear", "foo") == {"enc": "clear", "load": "foo"}
try:
sreq.destroy()
except Exception as exc: # pylint: disable=broad-except
pytest.fail(f"sreq.destroy threw an exception {exc}")
sreq.destroy()


@pytest.mark.slow_test
def test_clear_socket(sreq, echo_server):
# ensure we actually have an open socket and not just testing against
# no actual sockets created.
assert sreq.send("clear", "foo") == {"enc": "clear", "load": "foo"}
assert hasattr(sreq, "_socket")
sreq.clear_socket()
Expand Down
6 changes: 3 additions & 3 deletions tests/pytests/unit/test_payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,13 @@ def test_constants():

def test_package():
value = salt.utils.msgpack.dumps("test")
assert value == salt.payload.package("test")
assert salt.payload.package("test") == value


def test_unpackage():
value = [b"test"]
packed = salt.utils.msgpack.dumps(value)
assert value == salt.payload.unpackage(packed)
assert salt.payload.unpackage(packed) == value


def test_format_payload():
Expand All @@ -233,7 +233,7 @@ def test_format_payload():
enc = [b"test"]
kwargs = {"foo": "bar"}
payload = salt.payload.format_payload(enc=enc, kwargs=kwargs)
assert expected == payload
assert payload == expected


def test_SREQ_init():
Expand Down

0 comments on commit 38725e2

Please sign in to comment.