Ignore first row of logs when no uvloop

This commit is contained in:
Adam Hopkins 2018-12-30 14:07:21 +02:00
parent aea4a8ed33
commit 94e85686b5
No known key found for this signature in database
GPG Key ID: 7028135130579DF1

View File

@ -1,9 +1,14 @@
import logging import logging
import asyncio import asyncio
import pytest
from sanic.config import BASE_LOGO from sanic.config import BASE_LOGO
try:
import uvloop # noqa
ROW = 0
except BaseException:
ROW = 1
def test_logo_base(app, caplog): def test_logo_base(app, caplog):
server = app.create_server(debug=True) server = app.create_server(debug=True)
@ -18,7 +23,8 @@ def test_logo_base(app, caplog):
loop.run_until_complete(_server.wait_closed()) loop.run_until_complete(_server.wait_closed())
app.stop() app.stop()
assert caplog.record_tuples[0] == ("sanic.root", logging.DEBUG, BASE_LOGO) assert caplog.record_tuples[ROW][1] == logging.DEBUG
assert caplog.record_tuples[ROW][2] == BASE_LOGO
def test_logo_false(app, caplog): def test_logo_false(app, caplog):
@ -36,11 +42,8 @@ def test_logo_false(app, caplog):
loop.run_until_complete(_server.wait_closed()) loop.run_until_complete(_server.wait_closed())
app.stop() app.stop()
assert caplog.record_tuples[0] == ( assert caplog.record_tuples[ROW][1] == logging.INFO
"sanic.root", assert caplog.record_tuples[ROW][2] == "Goin' Fast @ http://127.0.0.1:8000"
logging.INFO,
"Goin' Fast @ http://127.0.0.1:8000",
)
def test_logo_true(app, caplog): def test_logo_true(app, caplog):
@ -58,7 +61,8 @@ def test_logo_true(app, caplog):
loop.run_until_complete(_server.wait_closed()) loop.run_until_complete(_server.wait_closed())
app.stop() app.stop()
assert caplog.record_tuples[0] == ("sanic.root", logging.DEBUG, BASE_LOGO) assert caplog.record_tuples[ROW][1] == logging.DEBUG
assert caplog.record_tuples[ROW][2] == BASE_LOGO
def test_logo_custom(app, caplog): def test_logo_custom(app, caplog):
@ -76,8 +80,5 @@ def test_logo_custom(app, caplog):
loop.run_until_complete(_server.wait_closed()) loop.run_until_complete(_server.wait_closed())
app.stop() app.stop()
assert caplog.record_tuples[0] == ( assert caplog.record_tuples[ROW][1] == logging.DEBUG
"sanic.root", assert caplog.record_tuples[ROW][2] == "My Custom Logo"
logging.DEBUG,
"My Custom Logo",
)