diff options
author | Bruno Oliveira <nicoddemus@gmail.com> | 2018-11-08 20:42:04 -0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-08 20:42:04 -0200 |
commit | 423e19909ecff177cf6c23b164279b90c2a64001 (patch) | |
tree | 9a6eab7597718543f73f9f47687047acf78e6b39 | |
parent | f06fe436492ea2fb1678455804519f75687d096a (diff) | |
parent | f48a26f59c448c55a83f83546949acddb073bd38 (diff) | |
download | pytest-423e19909ecff177cf6c23b164279b90c2a64001.tar.gz |
Merge pull request #4307 from fzarifian/fzarifian-pr4304
#4304 the stepwise plugin must be blocked on cacheprovider plugin block request
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | changelog/4304.bugfix.rst | 1 | ||||
-rw-r--r-- | src/_pytest/config/__init__.py | 5 | ||||
-rw-r--r-- | testing/test_pluginmanager.py | 18 |
4 files changed, 25 insertions, 0 deletions
@@ -76,6 +76,7 @@ Endre Galaczi Eric Hunsberger Eric Siegerman Erik M. Bray +Fabien Zarifian Fabio Zadrozny Feng Ma Florian Bruhin diff --git a/changelog/4304.bugfix.rst b/changelog/4304.bugfix.rst new file mode 100644 index 000000000..7d4dc033e --- /dev/null +++ b/changelog/4304.bugfix.rst @@ -0,0 +1 @@ +Block the ``stepwise`` plugin if ``cacheprovider`` is also blocked, as one depends on the other. diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index b42d6f843..0fc895546 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -477,6 +477,11 @@ class PytestPluginManager(PluginManager): def consider_pluginarg(self, arg): if arg.startswith("no:"): name = arg[3:] + # PR #4304 : remove stepwise if cacheprovider is blocked + if name == "cacheprovider": + self.set_blocked("stepwise") + self.set_blocked("pytest_stepwise") + self.set_blocked(name) if not name.startswith("pytest_"): self.set_blocked("pytest_" + name) diff --git a/testing/test_pluginmanager.py b/testing/test_pluginmanager.py index 0bee415f2..8e35290b7 100644 --- a/testing/test_pluginmanager.py +++ b/testing/test_pluginmanager.py @@ -380,3 +380,21 @@ class TestPytestPluginManagerBootstrapming(object): pytestpm.consider_preparse(["xyz", "-p", "no:abc"]) l2 = pytestpm.get_plugins() assert 42 not in l2 + + def test_plugin_prevent_register_stepwise_on_cacheprovider_unregister( + self, pytestpm + ): + """ From PR #4304 : The only way to unregister a module is documented at + the end of https://docs.pytest.org/en/latest/plugins.html. + + When unregister cacheprovider, then unregister stepwise too + """ + pytestpm.register(42, name="cacheprovider") + pytestpm.register(43, name="stepwise") + l1 = pytestpm.get_plugins() + assert 42 in l1 + assert 43 in l1 + pytestpm.consider_preparse(["xyz", "-p", "no:cacheprovider"]) + l2 = pytestpm.get_plugins() + assert 42 not in l2 + assert 43 not in l2 |