revert the destroy, and use s0undt3chs advise

This commit is contained in:
Thomas Phipps 2023-10-16 02:47:24 +00:00 committed by Pedro Algarvio
parent 841486c976
commit 38725e27d7
2 changed files with 9 additions and 8 deletions

View file

@ -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()

View file

@ -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():
@ -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():