Skip to content

Commit

Permalink
test: vsock: simplify assertions
Browse files Browse the repository at this point in the history
Remove `assert True` as that's just `pass` with extra steps. Remove `if
bla: assert False` as that's just `assert bla` with extra steps.

Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
  • Loading branch information
roypat committed Sep 13, 2024
1 parent 09e558a commit 9104425
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions tests/integration_tests/functional/test_vsock.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,11 @@ def test_vsock_transport_reset_h2g(
# it shouldn't receive anything.
worker.sock.settimeout(0.25)
response = worker.sock.recv(32)
if response != b"":
# If we reach here, it means the connection did not close.
assert False, "Connection not closed: response recieved '{}'".format(
response.decode("utf-8")
)
assert (
response == b""
), f"Connection not closed: response recieved '{response.decode('utf-8')}'"
except (SocketTimeout, ConnectionResetError, BrokenPipeError):
assert True
pass

# Terminate VM.
metrics = test_vm.flush_metrics()
Expand Down

0 comments on commit 9104425

Please sign in to comment.