|
|
|
@ -9,14 +9,18 @@ from flask.logging import default_handler, has_level_handler, \
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(autouse=True) |
|
|
|
|
def reset_logging(monkeypatch): |
|
|
|
|
def reset_logging(pytestconfig): |
|
|
|
|
root_handlers = logging.root.handlers[:] |
|
|
|
|
logging.root.handlers = [] |
|
|
|
|
root_level = logging.root.level |
|
|
|
|
|
|
|
|
|
logger = logging.getLogger('flask.app') |
|
|
|
|
logger.handlers = [] |
|
|
|
|
logger.setLevel(logging.NOTSET) |
|
|
|
|
|
|
|
|
|
logging_plugin = pytestconfig.pluginmanager.unregister( |
|
|
|
|
name='logging-plugin') |
|
|
|
|
|
|
|
|
|
yield |
|
|
|
|
|
|
|
|
|
logging.root.handlers[:] = root_handlers |
|
|
|
@ -25,6 +29,9 @@ def reset_logging(monkeypatch):
|
|
|
|
|
logger.handlers = [] |
|
|
|
|
logger.setLevel(logging.NOTSET) |
|
|
|
|
|
|
|
|
|
if logging_plugin: |
|
|
|
|
pytestconfig.pluginmanager.register(logging_plugin, 'logging-plugin') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_logger(app): |
|
|
|
|
assert app.logger.name == 'flask.app' |
|
|
|
|