From c32d23c1d45bc19c219b0972ec9600b6836e6178 Mon Sep 17 00:00:00 2001 From: torlando-tech Date: Sat, 15 Nov 2025 20:26:04 -0500 Subject: [PATCH] fix(tests): Move mock_driver fixture to module level for shared access MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes integration test failures where TestRealWorldScenario tests couldn't access the mock_driver fixture. The mock_driver fixture was defined inside TestPeripheralDisconnectCleanup class, making it unavailable to TestRealWorldScenario class. This caused pytest fixture lookup errors: - test_both_monitoring_mechanisms_detect_disconnect_idempotent - test_polling_catches_missed_dbus_signal Solution: Move mock_driver to module level (outside class) so all test classes can access it as a shared fixture. All integration tests now pass locally. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- tests/test_peripheral_disconnect_cleanup.py | 32 +++++++++++---------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/tests/test_peripheral_disconnect_cleanup.py b/tests/test_peripheral_disconnect_cleanup.py index 5ee9212..47f5518 100644 --- a/tests/test_peripheral_disconnect_cleanup.py +++ b/tests/test_peripheral_disconnect_cleanup.py @@ -45,24 +45,26 @@ if not hasattr(RNS, 'LOG_INFO'): RNS.log = Mock() +# Module-level fixture (shared across test classes) +@pytest.fixture +def mock_driver(): + """Create a mock Linux BLE driver with GATT server capabilities.""" + driver = Mock() + driver.loop = asyncio.new_event_loop() + driver._peers = {} # address -> peer_conn + driver._peers_lock = asyncio.Lock() + driver._log = Mock() + driver.on_device_disconnected = Mock() + + # Mock method that should be added + driver._handle_peripheral_disconnected = Mock() + + return driver + + class TestPeripheralDisconnectCleanup: """Test peripheral disconnection cleanup mechanisms.""" - @pytest.fixture - def mock_driver(self): - """Create a mock Linux BLE driver with GATT server capabilities.""" - driver = Mock() - driver.loop = asyncio.new_event_loop() - driver._peers = {} # address -> peer_conn - driver._peers_lock = asyncio.Lock() - driver._log = Mock() - driver.on_device_disconnected = Mock() - - # Mock method that should be added - driver._handle_peripheral_disconnected = Mock() - - return driver - @pytest.fixture def mock_gatt_server(self, mock_driver): """Create a mock GATT server with connected centrals."""