Skip to content

Commit d1702bd

Browse files
fix issue #1618 by considering plugin args first
additionally prevent unnecessary importation of blocked plugins
1 parent f2bb3df commit d1702bd

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

_pytest/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ def import_plugin(self, modname):
375375
# basename for historic purposes but must be imported with the
376376
# _pytest prefix.
377377
assert isinstance(modname, str)
378-
if self.get_plugin(modname) is not None:
378+
if self.get_plugin(modname) is not None or self.is_blocked(modname):
379379
return
380380
if modname in builtin_plugins:
381381
importspec = "_pytest." + modname
@@ -893,9 +893,9 @@ def fromdictargs(cls, option_dict, args):
893893
""" constructor useable for subprocesses. """
894894
config = get_config()
895895
config.option.__dict__.update(option_dict)
896-
config.parse(args, addopts=False)
897896
for x in config.option.plugins:
898897
config.pluginmanager.consider_pluginarg(x)
898+
config.parse(args, addopts=False)
899899
return config
900900

901901
def _processopt(self, opt):

testing/test_config.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def test_confcutdir(self, testdir):
7979
""")
8080
result = testdir.inline_run("--confcutdir=.")
8181
assert result.ret == 0
82-
82+
8383
class TestConfigCmdlineParsing:
8484
def test_parsing_again_fails(self, testdir):
8585
config = testdir.parseconfig()
@@ -352,6 +352,24 @@ def test_inifilename(self, tmpdir):
352352
assert config.inicfg.get('name') == 'value'
353353
assert config.inicfg.get('should_not_be_set') is None
354354

355+
def test_consider_plugin(self, testdir):
356+
pytest.importorskip('xdist')
357+
print testdir
358+
testdir.makepyfile(conftest="""
359+
pytest_plugins = ['plugin']
360+
""",
361+
plugin="""
362+
raise ImportError
363+
""",
364+
test_foo="""
365+
def test():
366+
pass
367+
""",
368+
)
369+
testdir.inline_run(
370+
'-n1',
371+
'-p', 'no:plugin')
372+
355373

356374
def test_options_on_small_file_do_not_blow_up(testdir):
357375
def runfiletest(opts):

0 commit comments

Comments
 (0)