From 59c58b3115346764125ff2ca8d21581c3b110ddb Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Tue, 6 Sep 2022 12:59:22 -0400 Subject: [PATCH] UT: Replace fn() with SubscriberSpy callable --- .../event_queue/test_pypubsub_island_event_queue.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/monkey/tests/unit_tests/monkey_island/cc/event_queue/test_pypubsub_island_event_queue.py b/monkey/tests/unit_tests/monkey_island/cc/event_queue/test_pypubsub_island_event_queue.py index 2546359fc..e3cce926f 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/event_queue/test_pypubsub_island_event_queue.py +++ b/monkey/tests/unit_tests/monkey_island/cc/event_queue/test_pypubsub_island_event_queue.py @@ -19,14 +19,15 @@ def event_queue() -> IIslandEventQueue: @pytest.fixture def event_queue_subscriber() -> Callable[..., None]: - def fn(topic=pub.AUTO_TOPIC): - fn.call_count += 1 - fn.call_topics |= {topic.getName()} + class SubscriberSpy: + call_count = 0 + call_topics = set() - fn.call_count = 0 - fn.call_topics = set() + def __call__(self, topic=pub.AUTO_TOPIC): + self.call_count += 1 + self.call_topics |= {topic.getName()} - return fn + return SubscriberSpy() def test_subscribe_publish__no_event_body(