Modify test_logo runner
This commit is contained in:
parent
05dd3b2e9d
commit
aea4a8ed33
|
@ -5,29 +5,36 @@ import pytest
|
||||||
from sanic.config import BASE_LOGO
|
from sanic.config import BASE_LOGO
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
def test_logo_base(app, caplog):
|
||||||
def server(app):
|
|
||||||
server = app.create_server(debug=True)
|
server = app.create_server(debug=True)
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.new_event_loop()
|
||||||
task = asyncio.ensure_future(server)
|
asyncio.set_event_loop(loop)
|
||||||
return loop, task
|
loop._stopping = False
|
||||||
|
|
||||||
|
|
||||||
def test_logo_base(app, server, caplog):
|
|
||||||
loop, task = server
|
|
||||||
with caplog.at_level(logging.DEBUG):
|
with caplog.at_level(logging.DEBUG):
|
||||||
runner = loop.run_until_complete(task)
|
_server = loop.run_until_complete(server)
|
||||||
runner.close()
|
|
||||||
|
_server.close()
|
||||||
|
loop.run_until_complete(_server.wait_closed())
|
||||||
|
app.stop()
|
||||||
|
|
||||||
assert caplog.record_tuples[0] == ("sanic.root", logging.DEBUG, BASE_LOGO)
|
assert caplog.record_tuples[0] == ("sanic.root", logging.DEBUG, BASE_LOGO)
|
||||||
|
|
||||||
|
|
||||||
def test_logo_false(app, server, caplog):
|
def test_logo_false(app, caplog):
|
||||||
app.config.LOGO = False
|
app.config.LOGO = False
|
||||||
loop, task = server
|
|
||||||
|
server = app.create_server(debug=True)
|
||||||
|
loop = asyncio.new_event_loop()
|
||||||
|
asyncio.set_event_loop(loop)
|
||||||
|
loop._stopping = False
|
||||||
|
|
||||||
with caplog.at_level(logging.DEBUG):
|
with caplog.at_level(logging.DEBUG):
|
||||||
runner = loop.run_until_complete(task)
|
_server = loop.run_until_complete(server)
|
||||||
runner.close()
|
|
||||||
|
_server.close()
|
||||||
|
loop.run_until_complete(_server.wait_closed())
|
||||||
|
app.stop()
|
||||||
|
|
||||||
assert caplog.record_tuples[0] == (
|
assert caplog.record_tuples[0] == (
|
||||||
"sanic.root",
|
"sanic.root",
|
||||||
|
@ -36,22 +43,38 @@ def test_logo_false(app, server, caplog):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_logo_true(app, server, caplog):
|
def test_logo_true(app, caplog):
|
||||||
app.config.LOGO = True
|
app.config.LOGO = True
|
||||||
loop, task = server
|
|
||||||
|
server = app.create_server(debug=True)
|
||||||
|
loop = asyncio.new_event_loop()
|
||||||
|
asyncio.set_event_loop(loop)
|
||||||
|
loop._stopping = False
|
||||||
|
|
||||||
with caplog.at_level(logging.DEBUG):
|
with caplog.at_level(logging.DEBUG):
|
||||||
runner = loop.run_until_complete(task)
|
_server = loop.run_until_complete(server)
|
||||||
runner.close()
|
|
||||||
|
_server.close()
|
||||||
|
loop.run_until_complete(_server.wait_closed())
|
||||||
|
app.stop()
|
||||||
|
|
||||||
assert caplog.record_tuples[0] == ("sanic.root", logging.DEBUG, BASE_LOGO)
|
assert caplog.record_tuples[0] == ("sanic.root", logging.DEBUG, BASE_LOGO)
|
||||||
|
|
||||||
|
|
||||||
def test_logo_custom(app, server, caplog):
|
def test_logo_custom(app, caplog):
|
||||||
app.config.LOGO = "My Custom Logo"
|
app.config.LOGO = "My Custom Logo"
|
||||||
loop, task = server
|
|
||||||
|
server = app.create_server(debug=True)
|
||||||
|
loop = asyncio.new_event_loop()
|
||||||
|
asyncio.set_event_loop(loop)
|
||||||
|
loop._stopping = False
|
||||||
|
|
||||||
with caplog.at_level(logging.DEBUG):
|
with caplog.at_level(logging.DEBUG):
|
||||||
runner = loop.run_until_complete(task)
|
_server = loop.run_until_complete(server)
|
||||||
runner.close()
|
|
||||||
|
_server.close()
|
||||||
|
loop.run_until_complete(_server.wait_closed())
|
||||||
|
app.stop()
|
||||||
|
|
||||||
assert caplog.record_tuples[0] == (
|
assert caplog.record_tuples[0] == (
|
||||||
"sanic.root",
|
"sanic.root",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user