Skip to content

Commit 423e199

Browse files
authored
Merge pull request #4307 from fzarifian/fzarifian-pr4304
#4304 the stepwise plugin must be blocked on cacheprovider plugin block request
2 parents f06fe43 + f48a26f commit 423e199

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ Endre Galaczi
7676
Eric Hunsberger
7777
Eric Siegerman
7878
Erik M. Bray
79+
Fabien Zarifian
7980
Fabio Zadrozny
8081
Feng Ma
8182
Florian Bruhin

changelog/4304.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Block the ``stepwise`` plugin if ``cacheprovider`` is also blocked, as one depends on the other.

src/_pytest/config/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,11 @@ def consider_preparse(self, args):
477477
def consider_pluginarg(self, arg):
478478
if arg.startswith("no:"):
479479
name = arg[3:]
480+
# PR #4304 : remove stepwise if cacheprovider is blocked
481+
if name == "cacheprovider":
482+
self.set_blocked("stepwise")
483+
self.set_blocked("pytest_stepwise")
484+
480485
self.set_blocked(name)
481486
if not name.startswith("pytest_"):
482487
self.set_blocked("pytest_" + name)

testing/test_pluginmanager.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,3 +380,21 @@ def test_plugin_prevent_register_unregistered_alredy_registered(self, pytestpm):
380380
pytestpm.consider_preparse(["xyz", "-p", "no:abc"])
381381
l2 = pytestpm.get_plugins()
382382
assert 42 not in l2
383+
384+
def test_plugin_prevent_register_stepwise_on_cacheprovider_unregister(
385+
self, pytestpm
386+
):
387+
""" From PR #4304 : The only way to unregister a module is documented at
388+
the end of https://docs.pytest.org/en/latest/plugins.html.
389+
390+
When unregister cacheprovider, then unregister stepwise too
391+
"""
392+
pytestpm.register(42, name="cacheprovider")
393+
pytestpm.register(43, name="stepwise")
394+
l1 = pytestpm.get_plugins()
395+
assert 42 in l1
396+
assert 43 in l1
397+
pytestpm.consider_preparse(["xyz", "-p", "no:cacheprovider"])
398+
l2 = pytestpm.get_plugins()
399+
assert 42 not in l2
400+
assert 43 not in l2

0 commit comments

Comments
 (0)