This commit is contained in:
Angus Hollands 2017-02-11 12:50:19 +00:00
parent 39720892ba
commit 252749f756

View File

@ -42,9 +42,10 @@ def test_single_listener(listener_name):
random_name_app = Sanic(''.join( random_name_app = Sanic(''.join(
[choice(ascii_letters) for _ in range(choice(range(5, 10)))])) [choice(ascii_letters) for _ in range(choice(range(5, 10)))]))
output = list() output = list()
start_stop_app( # Register listener
random_name_app, getattr(random_name_app, listener_name)(
**{listener_name: create_listener(listener_name, output)}) create_listener(listener_name, output))
start_stop_app(random_name_app)
assert random_name_app.name + listener_name == output.pop() assert random_name_app.name + listener_name == output.pop()
@ -52,9 +53,9 @@ def test_all_listeners():
random_name_app = Sanic(''.join( random_name_app = Sanic(''.join(
[choice(ascii_letters) for _ in range(choice(range(5, 10)))])) [choice(ascii_letters) for _ in range(choice(range(5, 10)))]))
output = list() output = list()
start_stop_app( for listener_name in AVAILABLE_LISTENERS:
random_name_app, listener = create_listener(listener_name, output)
**{listener_name: create_listener(listener_name, output) getattr(random_name_app, listener_name)(listener)
for listener_name in AVAILABLE_LISTENERS}) start_stop_app(random_name_app)
for listener_name in AVAILABLE_LISTENERS: for listener_name in AVAILABLE_LISTENERS:
assert random_name_app.name + listener_name == output.pop() assert random_name_app.name + listener_name == output.pop()