From 105f7e99604db9f0eabebb3b76ff6326663876e2 Mon Sep 17 00:00:00 2001 From: Michel Hidalgo Date: Wed, 29 Apr 2026 16:02:28 -0300 Subject: [PATCH 1/2] Clear logging caches before logging tests Signed-off-by: Michel Hidalgo --- synchros2/synchros2/logging.py | 8 ++++++++ synchros2/test/test_logging.py | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/synchros2/synchros2/logging.py b/synchros2/synchros2/logging.py index 6a6f2e1..6ce0bed 100644 --- a/synchros2/synchros2/logging.py +++ b/synchros2/synchros2/logging.py @@ -93,6 +93,14 @@ def log(message: str) -> bool: return log +def clear_logging_caches() -> None: + """Clears the caches of memoized logging functions. + + This is useful for testing purposes, to avoid interference between tests due to cached logging functions. + """ + make_logging_function.cache_clear() + + class MemoizingRcutilsLogger: """An alternative, more efficient implementation of RcutilsLogger. diff --git a/synchros2/test/test_logging.py b/synchros2/test/test_logging.py index 2fc1248..123670d 100644 --- a/synchros2/test/test_logging.py +++ b/synchros2/test/test_logging.py @@ -9,7 +9,7 @@ from rclpy.time import Time from synchros2.futures import unwrap_future -from synchros2.logging import LoggingSeverity, logs_to_ros +from synchros2.logging import LoggingSeverity, clear_logging_caches, logs_to_ros from synchros2.scope import ROSAwareScope from synchros2.subscription import Subscription @@ -29,6 +29,7 @@ def callback(message: Log) -> None: logger = verbose_ros.node.get_logger() logger.set_level(LoggingSeverity.INFO) + clear_logging_caches() # ensure no interference from previous tests assert not logger.debug("Debug message should not be logged") From c5f7c13e125da146a34b15e94186ccce288ed4fd Mon Sep 17 00:00:00 2001 From: Michel Hidalgo Date: Wed, 29 Apr 2026 16:02:46 -0300 Subject: [PATCH 2/2] Fix time sensitive tf listener test Signed-off-by: Michel Hidalgo --- synchros2/test/test_tf_listener_wrapper.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/synchros2/test/test_tf_listener_wrapper.py b/synchros2/test/test_tf_listener_wrapper.py index 500653f..e34aa9e 100644 --- a/synchros2/test/test_tf_listener_wrapper.py +++ b/synchros2/test/test_tf_listener_wrapper.py @@ -86,8 +86,7 @@ def test_existing_transform(ros: ROSAwareScope, tf_pair: Tuple[MockTfPublisherNo timestamp = ros.node.get_clock().now() trans = Transform(translation=Vector3(x=1.0, y=2.0, z=3.0), rotation=Quaternion(w=1.0, x=0.0, y=0.0, z=0.0)) tf_publisher.publish_transform(trans, timestamp) - time.sleep(0.2) - t = tf_listener.lookup_a_tform_b(FRAME_ID, CHILD_FRAME_ID, timestamp) + t = tf_listener.lookup_a_tform_b(FRAME_ID, CHILD_FRAME_ID, timestamp, timeout_sec=10.0, wait_for_frames=True) assert equal_transform(t.transform, trans)