From e905f6eddfbc65250aaa3d16c94fb7c564d2cb20 Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Wed, 10 Aug 2022 15:41:03 +0530 Subject: [PATCH] UT: Define functions instead of lambda expressions in PyPubSubEventQueue tests since flake8 complains --- .../event_queue/test_pypubsub_event_queue.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/monkey/tests/unit_tests/common/event_queue/test_pypubsub_event_queue.py b/monkey/tests/unit_tests/common/event_queue/test_pypubsub_event_queue.py index db240dd3d..1d2fc4fd1 100644 --- a/monkey/tests/unit_tests/common/event_queue/test_pypubsub_event_queue.py +++ b/monkey/tests/unit_tests/common/event_queue/test_pypubsub_event_queue.py @@ -36,12 +36,18 @@ def subscriber_2_calls(): @pytest.fixture def subscriber_1(subscriber_1_calls): - return lambda event, topic=pub.AUTO_TOPIC: subscriber_1_calls.append(topic.getName()) + def fn(event, topic=pub.AUTO_TOPIC): + subscriber_1_calls.append(topic.getName()) + + return fn @pytest.fixture def subscriber_2(subscriber_2_calls): - return lambda event, topic=pub.AUTO_TOPIC: subscriber_2_calls.append(topic.getName()) + def fn(event, topic=pub.AUTO_TOPIC): + subscriber_2_calls.append(topic.getName()) + + return fn @pytest.mark.usefixtures("subscriber_1", "subscriber_2", "subscriber_1_calls", "subscriber_2_calls") @@ -57,7 +63,9 @@ def test_topic_subscription(subscriber_1, subscriber_2, subscriber_1_calls, subs def test_subscribe_all(): subscriber_calls = [] - subscriber = lambda topic=pub.AUTO_TOPIC: subscriber_calls.append(topic.getName()) + + def subscriber(topic=pub.AUTO_TOPIC): + subscriber_calls.append(topic.getName()) pypubsub_event_queue.subscribe_all(subscriber) pypubsub_event_queue.publish(EventType)