Skip to content

Commit

Permalink
fix issue pytest-dev#1618 by considering plugin args first
Browse files Browse the repository at this point in the history
additionally prevent unnecessary importation of blocked plugins
  • Loading branch information
RonnyPfannschmidt committed Jun 25, 2016
1 parent f2bb3df commit d1702bd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
4 changes: 2 additions & 2 deletions _pytest/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,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
Expand Down Expand Up @@ -893,9 +893,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):
Expand Down
20 changes: 19 additions & 1 deletion testing/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit d1702bd

Please sign in to comment.