Merge pull request #2554 from camilojimenez/2550-some-tests-fail
fix non-passing tests for logging on pytest >= 3.3.0
This commit is contained in:
commit
27a7171d42
1 changed files with 8 additions and 1 deletions
|
|
@ -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'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue