diff --git a/CHANGELOG.rst b/CHANGELOG.rst index b9315c9ca4f..75ec393d5a4 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -3,7 +3,9 @@ **Changes** -* +* fix (`#1618`_): properly consider explicitly blocked plugins + by considering pluginargs before setuptools plugin + (which avoids calling addopts from a plugin that was asked to be disabled) * diff --git a/_pytest/config.py b/_pytest/config.py index 463d8f04f9d..c78e5cb3c07 100644 --- a/_pytest/config.py +++ b/_pytest/config.py @@ -376,7 +376,7 @@ def import_plugin(self, modname): # basename for historic purposes but must be imported with the # _pytest prefix. assert isinstance(modname, str) - if self.get_plugin(modname) is not None: + if self.get_plugin(modname) is not None or self.is_blocked(modname): return if modname in builtin_plugins: importspec = "_pytest." + modname @@ -894,9 +894,9 @@ def fromdictargs(cls, option_dict, args): """ constructor useable for subprocesses. """ config = get_config() config.option.__dict__.update(option_dict) - config.parse(args, addopts=False) for x in config.option.plugins: config.pluginmanager.consider_pluginarg(x) + config.parse(args, addopts=False) return config def _processopt(self, opt): diff --git a/testing/test_config.py b/testing/test_config.py index fe550dbdd2e..9950504ff86 100644 --- a/testing/test_config.py +++ b/testing/test_config.py @@ -79,7 +79,7 @@ def test_confcutdir(self, testdir): """) result = testdir.inline_run("--confcutdir=.") assert result.ret == 0 - + class TestConfigCmdlineParsing: def test_parsing_again_fails(self, testdir): config = testdir.parseconfig() @@ -352,6 +352,25 @@ def test_inifilename(self, tmpdir): assert config.inicfg.get('name') == 'value' assert config.inicfg.get('should_not_be_set') is None + @pytest.mark.issue1618 + def test_consider_plugin(self, testdir): + pytest.importorskip('xdist') + print (testdir) + testdir.makepyfile(conftest=""" + pytest_plugins = ['plugin'] + """, + plugin=""" + raise ImportError + """, + test_foo=""" + def test(): + pass + """, + ) + res = testdir.inline_run( + '-n1', + '-p', 'no:plugin') + assert res.res == 0 def test_options_on_small_file_do_not_blow_up(testdir): def runfiletest(opts): @@ -671,4 +690,4 @@ def test_multiple_options(pytestconfig): "ini2:url=/tmp/user2?a=b&d=e", "ini3:True", "ini4:False" - ]) \ No newline at end of file + ])