From e30a73fd1b2bd18a8ac12d2af7f5350e6ebc0fe4 Mon Sep 17 00:00:00 2001 From: torlando-tech Date: Tue, 30 Dec 2025 14:59:28 -0500 Subject: [PATCH] fix: patch RNS.log in BLEInterface module's namespace MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous patch changed RNS.log in the test's namespace, but BLEInterface.py imports RNS at module load time. To capture log calls from _address_changed_callback(), we need to patch RNS.log where it's used: ble_reticulum.BLEInterface.RNS.log 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- tests/test_identity_cache.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/test_identity_cache.py b/tests/test_identity_cache.py index 33bc9c8..f723bdc 100644 --- a/tests/test_identity_cache.py +++ b/tests/test_identity_cache.py @@ -339,11 +339,15 @@ class TestAddressChangedCallback: assert old_mac not in ble_interface.address_to_identity assert old_mac not in ble_interface._identity_cache - # Patch RNS.log at module level to capture calls - import RNS - original_log = RNS.log + # Patch RNS.log in the BLEInterface module's namespace + from ble_reticulum import BLEInterface as ble_module log_calls = [] - RNS.log = lambda msg, level=4: log_calls.append((msg, level)) + + def capture_log(msg, level=4): + log_calls.append((msg, level)) + + original_log = ble_module.RNS.log + ble_module.RNS.log = capture_log try: # Call address changed callback - should not crash @@ -354,7 +358,7 @@ class TestAddressChangedCallback: assert any("no identity found" in str(msg).lower() for msg, level in log_calls), \ f"Expected 'no identity found' warning, got: {log_calls}" finally: - RNS.log = original_log + ble_module.RNS.log = original_log class TestCacheTTL: