Merge pull request #4307 from fzarifian/fzarifian-pr4304

#4304 the stepwise plugin must be blocked on cacheprovider plugin block request
This commit is contained in:
Bruno Oliveira 2018-11-08 20:42:04 -02:00 committed by GitHub
commit 423e19909e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 0 deletions

View File

@ -76,6 +76,7 @@ Endre Galaczi
Eric Hunsberger
Eric Siegerman
Erik M. Bray
Fabien Zarifian
Fabio Zadrozny
Feng Ma
Florian Bruhin

View File

@ -0,0 +1 @@
Block the ``stepwise`` plugin if ``cacheprovider`` is also blocked, as one depends on the other.

View File

@ -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)

View File

@ -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