Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ Endre Galaczi
Eric Hunsberger
Eric Siegerman
Erik M. Bray
Fabien Zarifian
Fabio Zadrozny
Feng Ma
Florian Bruhin
Expand Down
1 change: 1 addition & 0 deletions changelog/4304.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Block the ``stepwise`` plugin if ``cacheprovider`` is also blocked, as one depends on the other.
5 changes: 5 additions & 0 deletions src/_pytest/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,11 @@ def consider_preparse(self, args):
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)
Expand Down
18 changes: 18 additions & 0 deletions testing/test_pluginmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,3 +380,21 @@ def test_plugin_prevent_register_unregistered_alredy_registered(self, pytestpm):
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