offer a semi-internal method to create a config object in subprocesses
(helps pytest-xdist plugin to fix issue34)
This commit is contained in:
parent
ed6d2537bc
commit
1d40abadc4
|
@ -252,6 +252,16 @@ class Config(object):
|
||||||
self.hook = self.pluginmanager.hook
|
self.hook = self.pluginmanager.hook
|
||||||
self._inicache = {}
|
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):
|
def _onimportconftest(self, conftestmodule):
|
||||||
self.trace("loaded conftestmodule %r" %(conftestmodule,))
|
self.trace("loaded conftestmodule %r" %(conftestmodule,))
|
||||||
self.pluginmanager.consider_conftest(conftestmodule)
|
self.pluginmanager.consider_conftest(conftestmodule)
|
||||||
|
|
|
@ -164,14 +164,17 @@ class PluginManager(object):
|
||||||
def consider_preparse(self, args):
|
def consider_preparse(self, args):
|
||||||
for opt1,opt2 in zip(args, args[1:]):
|
for opt1,opt2 in zip(args, args[1:]):
|
||||||
if opt1 == "-p":
|
if opt1 == "-p":
|
||||||
if opt2.startswith("no:"):
|
self.consider_pluginarg(opt2)
|
||||||
name = opt2[3:]
|
|
||||||
if self.getplugin(name) is not None:
|
def consider_pluginarg(self, arg):
|
||||||
self.unregister(None, name=name)
|
if arg.startswith("no:"):
|
||||||
self._name2plugin[name] = -1
|
name = arg[3:]
|
||||||
else:
|
if self.getplugin(name) is not None:
|
||||||
if self.getplugin(opt2) is None:
|
self.unregister(None, name=name)
|
||||||
self.import_plugin(opt2)
|
self._name2plugin[name] = -1
|
||||||
|
else:
|
||||||
|
if self.getplugin(arg) is None:
|
||||||
|
self.import_plugin(arg)
|
||||||
|
|
||||||
def consider_conftest(self, conftestmodule):
|
def consider_conftest(self, conftestmodule):
|
||||||
if self.register(conftestmodule, name=conftestmodule.__file__):
|
if self.register(conftestmodule, name=conftestmodule.__file__):
|
||||||
|
|
Loading…
Reference in New Issue