diff --git a/tests/test_server_events.py b/tests/test_server_events.py index fce98440..2b8cde6a 100644 --- a/tests/test_server_events.py +++ b/tests/test_server_events.py @@ -42,9 +42,10 @@ def test_single_listener(listener_name): random_name_app = Sanic(''.join( [choice(ascii_letters) for _ in range(choice(range(5, 10)))])) output = list() - start_stop_app( - random_name_app, - **{listener_name: create_listener(listener_name, output)}) + # Register listener + getattr(random_name_app, listener_name)( + create_listener(listener_name, output)) + start_stop_app(random_name_app) assert random_name_app.name + listener_name == output.pop() @@ -52,9 +53,9 @@ def test_all_listeners(): random_name_app = Sanic(''.join( [choice(ascii_letters) for _ in range(choice(range(5, 10)))])) output = list() - start_stop_app( - random_name_app, - **{listener_name: create_listener(listener_name, output) - for listener_name in AVAILABLE_LISTENERS}) + for listener_name in AVAILABLE_LISTENERS: + listener = create_listener(listener_name, output) + getattr(random_name_app, listener_name)(listener) + start_stop_app(random_name_app) for listener_name in AVAILABLE_LISTENERS: assert random_name_app.name + listener_name == output.pop()