From ce30896cd20953f4eca1f2acac904c3f7a8e0c78 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 5 Dec 2017 20:02:56 +0100 Subject: [PATCH] Also blacklist pytest-capturelog plugin This is the older plugin before pytest-catchlog was around. Apparently there are people still using it. Fixes #3004 --- _pytest/config.py | 7 ++++--- changelog/3004.bugfix | 1 + testing/deprecated_test.py | 9 +++++---- 3 files changed, 10 insertions(+), 7 deletions(-) create mode 100644 changelog/3004.bugfix diff --git a/_pytest/config.py b/_pytest/config.py index 499c8079d..ce7468f72 100644 --- a/_pytest/config.py +++ b/_pytest/config.py @@ -242,9 +242,10 @@ class PytestPluginManager(PluginManager): return opts def register(self, plugin, name=None): - if name == 'pytest_catchlog': - self._warn('pytest-catchlog plugin has been merged into the core, ' - 'please remove it from your requirements.') + if name in ['pytest_catchlog', 'pytest_capturelog']: + self._warn('{0} plugin has been merged into the core, ' + 'please remove it from your requirements.'.format( + name.replace('_', '-'))) return ret = super(PytestPluginManager, self).register(plugin, name) if ret: diff --git a/changelog/3004.bugfix b/changelog/3004.bugfix new file mode 100644 index 000000000..22f4fd1d7 --- /dev/null +++ b/changelog/3004.bugfix @@ -0,0 +1 @@ +The pytest-capturelog plugin is now also blacklisted, avoiding errors when running pytest with it still installed. diff --git a/testing/deprecated_test.py b/testing/deprecated_test.py index 11c4ad43c..420070d91 100644 --- a/testing/deprecated_test.py +++ b/testing/deprecated_test.py @@ -114,14 +114,15 @@ def test_terminal_reporter_writer_attr(pytestconfig): assert terminal_reporter.writer is terminal_reporter._tw -def test_pytest_catchlog_deprecated(testdir): +@pytest.mark.parametrize('plugin', ['catchlog', 'capturelog']) +def test_pytest_catchlog_deprecated(testdir, plugin): testdir.makepyfile(""" def test_func(pytestconfig): - pytestconfig.pluginmanager.register(None, 'pytest_catchlog') - """) + pytestconfig.pluginmanager.register(None, 'pytest_{0}') + """.format(plugin)) res = testdir.runpytest() assert res.ret == 0 res.stdout.fnmatch_lines([ - "*pytest-catchlog plugin has been merged into the core*", + "*pytest-*log plugin has been merged into the core*", "*1 passed, 1 warnings*", ])