Skip to content

Commit

Permalink
Fix app.create_server calls
Browse files Browse the repository at this point in the history
  • Loading branch information
denismakogon committed Jan 15, 2019
1 parent 0242bc9 commit eed22a7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
6 changes: 4 additions & 2 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
12 changes: 8 additions & 4 deletions tests/test_logo.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@


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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion tests/test_server_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ class MySanicDb:
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)

0 comments on commit eed22a7

Please sign in to comment.