use config fixture, get plugin via unregister

This commit is contained in:
David Lord 2017-12-14 12:20:03 -08:00
parent 33fa580947
commit 604cc758fb
No known key found for this signature in database
GPG key ID: 7A1C87E3F5BC42A8

View file

@ -9,17 +9,17 @@ 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 = pytest.config.pluginmanager.getplugin('logging-plugin')
pytest.config.pluginmanager.unregister(name='logging-plugin')
logging.root.handlers = []
logging_plugin = pytestconfig.pluginmanager.unregister(
name='logging-plugin')
yield
@ -30,7 +30,7 @@ def reset_logging(monkeypatch):
logger.setLevel(logging.NOTSET)
if logging_plugin:
pytest.config.pluginmanager.register(logging_plugin, 'logging-plugin')
pytestconfig.pluginmanager.register(logging_plugin, 'logging-plugin')
def test_logger(app):