From eed22a7a24289d14bb64bd5f360c6fa3fc66132c Mon Sep 17 00:00:00 2001 From: Denis Makogon Date: Tue, 15 Jan 2019 15:17:57 +0200 Subject: [PATCH] Fix app.create_server calls --- tests/test_app.py | 2 +- tests/test_config.py | 6 ++++-- tests/test_logo.py | 12 ++++++++---- tests/test_server_events.py | 3 ++- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/tests/test_app.py b/tests/test_app.py index 91cb9ca5..715b7a6f 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -25,7 +25,7 @@ def test_create_asyncio_server(app): asyncio_srv_coro = app.create_server(return_asyncio_server=True) assert isawaitable(asyncio_srv_coro) srv = loop.run_until_complete(asyncio_srv_coro) - assert isinstance(srv, asyncio_base_events.Server) + assert srv.is_serving() is True def test_asyncio_server_start_serving(app): diff --git a/tests/test_config.py b/tests/test_config.py index fe4b97b9..241a2566 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -231,10 +231,12 @@ async def test_config_access_log_passing_in_create_server(app): async def _request(sanic, loop): app.stop() - await app.create_server(port=1341, access_log=False) + await app.create_server(port=1341, access_log=False, + return_asyncio_server=True) assert app.config.ACCESS_LOG == False - await app.create_server(port=1342, access_log=True) + await app.create_server(port=1342, access_log=True, + return_asyncio_server=True) assert app.config.ACCESS_LOG == True diff --git a/tests/test_logo.py b/tests/test_logo.py index 1deb46f6..901d7b8d 100644 --- a/tests/test_logo.py +++ b/tests/test_logo.py @@ -12,7 +12,8 @@ except BaseException: def test_logo_base(app, caplog): - server = app.create_server(debug=True) + server = app.create_server( + debug=True, return_asyncio_server=True) loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) loop._stopping = False @@ -31,7 +32,8 @@ def test_logo_base(app, caplog): def test_logo_false(app, caplog): app.config.LOGO = False - server = app.create_server(debug=True) + server = app.create_server( + debug=True, return_asyncio_server=True) loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) loop._stopping = False @@ -50,7 +52,8 @@ def test_logo_false(app, caplog): def test_logo_true(app, caplog): app.config.LOGO = True - server = app.create_server(debug=True) + server = app.create_server( + debug=True, return_asyncio_server=True) loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) loop._stopping = False @@ -69,7 +72,8 @@ def test_logo_true(app, caplog): def test_logo_custom(app, caplog): app.config.LOGO = "My Custom Logo" - server = app.create_server(debug=True) + server = app.create_server( + debug=True, return_asyncio_server=True) loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) loop._stopping = False diff --git a/tests/test_server_events.py b/tests/test_server_events.py index 0dc344df..2e2cf513 100644 --- a/tests/test_server_events.py +++ b/tests/test_server_events.py @@ -83,7 +83,8 @@ async def test_trigger_before_events_create_server(app): async def init_db(app, loop): app.db = MySanicDb() - await app.create_server() + await app.create_server( + debug=True, return_asyncio_server=True) assert hasattr(app, "db") assert isinstance(app.db, MySanicDb)