diff --git a/_pytest/config.py b/_pytest/config.py index 0c6c2e162..79a26afb4 100644 --- a/_pytest/config.py +++ b/_pytest/config.py @@ -252,6 +252,16 @@ class Config(object): self.hook = self.pluginmanager.hook self._inicache = {} + @classmethod + def fromdictargs(cls, option_dict, args): + """ constructor useable for subprocesses. """ + config = cls() + config._preparse(args, addopts=False) + config.option.__dict__.update(option_dict) + for x in config.option.plugins: + config.pluginmanager.consider_pluginarg(x) + return config + def _onimportconftest(self, conftestmodule): self.trace("loaded conftestmodule %r" %(conftestmodule,)) self.pluginmanager.consider_conftest(conftestmodule) diff --git a/_pytest/core.py b/_pytest/core.py index 2bd110f51..abe7a26de 100644 --- a/_pytest/core.py +++ b/_pytest/core.py @@ -164,14 +164,17 @@ class PluginManager(object): def consider_preparse(self, args): for opt1,opt2 in zip(args, args[1:]): if opt1 == "-p": - if opt2.startswith("no:"): - name = opt2[3:] - if self.getplugin(name) is not None: - self.unregister(None, name=name) - self._name2plugin[name] = -1 - else: - if self.getplugin(opt2) is None: - self.import_plugin(opt2) + self.consider_pluginarg(opt2) + + def consider_pluginarg(self, arg): + if arg.startswith("no:"): + name = arg[3:] + if self.getplugin(name) is not None: + self.unregister(None, name=name) + self._name2plugin[name] = -1 + else: + if self.getplugin(arg) is None: + self.import_plugin(arg) def consider_conftest(self, conftestmodule): if self.register(conftestmodule, name=conftestmodule.__file__):