Skip to content

Quickly sandbox your AI agent.

Python

tests: fix ruff format and de-flake test_stop_closes_listener

Jace Medlinb1b2c1676b5d
diff --git a/tests/unit/smb/test_smb_server.py b/tests/unit/smb/test_smb_server.py
index fed6816..76fd191 100644
--- a/tests/unit/smb/test_smb_server.py
+++ b/tests/unit/smb/test_smb_server.py
@@ -943,8 +943,7 @@ class TestFsInfoSizes:
out = _handle_fs_info(info_class, tmp_path)
assert out is not None, f"class {info_class} returned None"
assert len(out) >= minimum, (
- f"FS info class {info_class} returned {len(out)} bytes, "
- f"expected >= {minimum}"
+ f"FS info class {info_class} returned {len(out)} bytes, expected >= {minimum}"
)
def test_fs_sector_size_is_28_bytes(self, tmp_path):
diff --git a/tests/unit/test_smb_tcp_server.py b/tests/unit/test_smb_tcp_server.py
index ee6e8c1..85047e9 100644
--- a/tests/unit/test_smb_tcp_server.py
+++ b/tests/unit/test_smb_tcp_server.py
@@ -88,11 +88,17 @@ class TestLifecycle:
def test_stop_closes_listener(self):
srv = QuicksandSMBTCPServer()
srv.start()
- port = srv.port
+ assert srv.port != 0
+ assert srv._accept_thread is not None and srv._accept_thread.is_alive()
srv.stop()
+ # stop() must tear down cleanly: port reset, listener socket dropped,
+ # accept thread joined. (We don't assert that connecting to the freed
+ # port now refuses — the OS may briefly accept or reuse an ephemeral
+ # port after close, which makes that check racy on Linux CI.)
assert srv.port == 0
- with pytest.raises(OSError):
- socket.create_connection(("127.0.0.1", port), timeout=1)
+ assert srv._server_sock is None
+ assert srv._accept_thread is None
+ assert srv._stopping.is_set()
class TestShareConfig: