Reuse app fixture in tests

This commit is contained in:
dmitry.dygalo
2018-08-26 16:43:14 +02:00
parent 30e6a310f1
commit fec81ffe73
28 changed files with 253 additions and 510 deletions

View File

@@ -23,7 +23,7 @@ def reset_logging():
reload(logging)
def test_log():
def test_log(app):
log_stream = StringIO()
for handler in logging.root.handlers[:]:
logging.root.removeHandler(handler)
@@ -33,7 +33,6 @@ def test_log():
stream=log_stream
)
log = logging.getLogger()
app = Sanic('test_logging')
rand_string = str(uuid.uuid4())
@app.route('/')
@@ -80,9 +79,8 @@ def test_logging_pass_customer_logconfig():
@pytest.mark.parametrize('debug', (True, False, ))
def test_log_connection_lost(debug, monkeypatch):
def test_log_connection_lost(app, debug, monkeypatch):
""" Should not log Connection lost exception on non debug """
app = Sanic('connection_lost')
stream = StringIO()
root = logging.getLogger('root')
root.addHandler(logging.StreamHandler(stream))