From f33da4336c240a38b276b9eabd0c90b5d3436b86 Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Sat, 25 Jun 2016 18:32:45 +0200 Subject: [PATCH 1/7] fix issue #1618 by considering plugin args first additionally prevent unnecessary importation of blocked plugins --- _pytest/config.py | 4 ++-- testing/test_config.py | 20 +++++++++++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) 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..faccc608538 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,24 @@ def test_inifilename(self, tmpdir): assert config.inicfg.get('name') == 'value' assert config.inicfg.get('should_not_be_set') is None + 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 + """, + ) + testdir.inline_run( + '-n1', + '-p', 'no:plugin') + def test_options_on_small_file_do_not_blow_up(testdir): def runfiletest(opts): From 8a4b00dd4d4f041411e1b545046b0e39bda5499b Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Sat, 25 Jun 2016 18:36:07 +0200 Subject: [PATCH 2/7] add changelog for #1618 --- CHANGELOG.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index b9315c9ca4f..dd0998ad139 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -3,7 +3,7 @@ **Changes** -* +* fix (`#1618`_): properly consider explicitly blocked plugins * @@ -31,6 +31,7 @@ .. _#607: https://github.com/pytest-dev/pytest/issues/607 .. _#1519: https://github.com/pytest-dev/pytest/pull/1519 .. _#1664: https://github.com/pytest-dev/pytest/pull/1664 +.. _#1618: https://github.com/pytest-dev/pytest/pull/1618 2.10.0.dev1 From 3c246f550888e37f00dd550f3e6a9c0bd7557037 Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Mon, 27 Jun 2016 13:20:48 +0200 Subject: [PATCH 3/7] refer the issue #1618 in the test Fix #1618 --- testing/test_config.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/testing/test_config.py b/testing/test_config.py index faccc608538..ee92efbc895 100644 --- a/testing/test_config.py +++ b/testing/test_config.py @@ -352,6 +352,7 @@ 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 @@ -689,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 + ]) From 64cd2f1a861e30b8997937798fada6671c59154e Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Mon, 27 Jun 2016 13:30:12 +0200 Subject: [PATCH 4/7] config tests: use python3 compatible print --- testing/test_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/test_config.py b/testing/test_config.py index ee92efbc895..7c3f79c3e69 100644 --- a/testing/test_config.py +++ b/testing/test_config.py @@ -355,7 +355,7 @@ def test_inifilename(self, tmpdir): @pytest.mark.issue1618 def test_consider_plugin(self, testdir): pytest.importorskip('xdist') - print testdir + print (testdir) testdir.makepyfile(conftest=""" pytest_plugins = ['plugin'] """, From 5f61109e32ca7073f2330f4204510ea7a59bb1de Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Mon, 27 Jun 2016 13:34:03 +0200 Subject: [PATCH 5/7] remove duplicate changelog referenece after rebase --- CHANGELOG.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index dd0998ad139..db87fdf5141 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -31,7 +31,6 @@ .. _#607: https://github.com/pytest-dev/pytest/issues/607 .. _#1519: https://github.com/pytest-dev/pytest/pull/1519 .. _#1664: https://github.com/pytest-dev/pytest/pull/1664 -.. _#1618: https://github.com/pytest-dev/pytest/pull/1618 2.10.0.dev1 From 9e19507e8e53a752b21e5ccff8747df6085328c7 Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Thu, 30 Jun 2016 11:00:40 +0200 Subject: [PATCH 6/7] extend changelog entry for #1618 --- CHANGELOG.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index db87fdf5141..75ec393d5a4 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,8 @@ **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) * From 2592c26e2523568714bf8051230de678701e79b6 Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Wed, 6 Jul 2016 13:21:28 +0200 Subject: [PATCH 7/7] assert test execution outcome for #1618 test --- testing/test_config.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testing/test_config.py b/testing/test_config.py index 7c3f79c3e69..9950504ff86 100644 --- a/testing/test_config.py +++ b/testing/test_config.py @@ -367,10 +367,10 @@ def test(): pass """, ) - testdir.inline_run( + 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):