From c55ca155e90caa2c2b890f3bd8c765c0dec1b438 Mon Sep 17 00:00:00 2001 From: Fabien ZARIFIAN Date: Sun, 4 Nov 2018 21:55:56 +0100 Subject: [PATCH 1/8] Update __init__.py #4304 --- src/_pytest/config/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index 6fbf8144a..33c6aaac7 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -476,6 +476,8 @@ class PytestPluginManager(PluginManager): def consider_pluginarg(self, arg): if arg.startswith("no:"): name = arg[3:] + if name == "cacheprovider": + self.consider_pluginarg("no:stepwise") self.set_blocked(name) if not name.startswith("pytest_"): self.set_blocked("pytest_" + name) From a447dc86fb013b7d0fac49220c5e893e6a282372 Mon Sep 17 00:00:00 2001 From: Fabien ZARIFIAN Date: Mon, 5 Nov 2018 00:14:35 +0100 Subject: [PATCH 2/8] Add test to branch --- testing/test_pluginmanager.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/testing/test_pluginmanager.py b/testing/test_pluginmanager.py index 0bee415f2..81a3a291e 100644 --- a/testing/test_pluginmanager.py +++ b/testing/test_pluginmanager.py @@ -380,3 +380,20 @@ 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 + From 1793ac38a93e02103ec7892b0458b4273fb75a2b Mon Sep 17 00:00:00 2001 From: Fabien ZARIFIAN Date: Mon, 5 Nov 2018 00:21:12 +0100 Subject: [PATCH 3/8] Update __init__.py --- src/_pytest/config/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index 33c6aaac7..5f5ddd81c 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -476,6 +476,7 @@ 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.consider_pluginarg("no:stepwise") self.set_blocked(name) From db70c758074ae29fc8b1519f00954f72c0354d41 Mon Sep 17 00:00:00 2001 From: Fabien ZARIFIAN Date: Mon, 5 Nov 2018 00:36:25 +0100 Subject: [PATCH 4/8] Create 4304.bugfix.rst --- changelog/4304.bugfix.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/4304.bugfix.rst diff --git a/changelog/4304.bugfix.rst b/changelog/4304.bugfix.rst new file mode 100644 index 000000000..cb71ea168 --- /dev/null +++ b/changelog/4304.bugfix.rst @@ -0,0 +1 @@ +The stepwise plugin must be blocked on cacheprovider plugin block request From 5f61f0d2cb4fbda9724306179353f3d85961507e Mon Sep 17 00:00:00 2001 From: Fabien ZARIFIAN Date: Mon, 5 Nov 2018 10:51:15 +0100 Subject: [PATCH 5/8] Update __init__.py As mentionned by @RonnyPfannschmidt, use set_blocked on module stepwise (and it's brother pytest_stepwise like consider_pluginarg method does) --- src/_pytest/config/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index 5f5ddd81c..d27fd7d58 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -478,7 +478,9 @@ class PytestPluginManager(PluginManager): name = arg[3:] # PR #4304 : remove stepwise if cacheprovider is blocked if name == "cacheprovider": - self.consider_pluginarg("no:stepwise") + self.set_blocked("stepwise") + self.set_blocked("pytest_stepwise") + self.set_blocked(name) if not name.startswith("pytest_"): self.set_blocked("pytest_" + name) From 9a884f1ccb11c332cf57427c67476bc5f2ef66e4 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Wed, 7 Nov 2018 18:30:13 -0200 Subject: [PATCH 6/8] Improve changelog a bit --- changelog/4304.bugfix.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog/4304.bugfix.rst b/changelog/4304.bugfix.rst index cb71ea168..7d4dc033e 100644 --- a/changelog/4304.bugfix.rst +++ b/changelog/4304.bugfix.rst @@ -1 +1 @@ -The stepwise plugin must be blocked on cacheprovider plugin block request +Block the ``stepwise`` plugin if ``cacheprovider`` is also blocked, as one depends on the other. From 17b8e2d45b0e7fefdd07487391ddef6795ce4a12 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Wed, 7 Nov 2018 18:32:23 -0200 Subject: [PATCH 7/8] Fix linting --- testing/test_pluginmanager.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/testing/test_pluginmanager.py b/testing/test_pluginmanager.py index 81a3a291e..8e35290b7 100644 --- a/testing/test_pluginmanager.py +++ b/testing/test_pluginmanager.py @@ -380,11 +380,13 @@ 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): + + 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") @@ -396,4 +398,3 @@ class TestPytestPluginManagerBootstrapming(object): l2 = pytestpm.get_plugins() assert 42 not in l2 assert 43 not in l2 - From f48a26f59c448c55a83f83546949acddb073bd38 Mon Sep 17 00:00:00 2001 From: Fabien ZARIFIAN Date: Thu, 8 Nov 2018 08:12:08 +0100 Subject: [PATCH 8/8] Update AUTHORS --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index dabeb1c06..777eda324 100644 --- a/AUTHORS +++ b/AUTHORS @@ -76,6 +76,7 @@ Endre Galaczi Eric Hunsberger Eric Siegerman Erik M. Bray +Fabien Zarifian Fabio Zadrozny Feng Ma Florian Bruhin