本文整理汇总了Python中_pytest.config.Config.fromdictargs方法的典型用法代码示例。如果您正苦于以下问题:Python Config.fromdictargs方法的具体用法?Python Config.fromdictargs怎么用?Python Config.fromdictargs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类_pytest.config.Config
的用法示例。
在下文中一共展示了Config.fromdictargs方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: remote_initconfig
# 需要导入模块: from _pytest.config import Config [as 别名]
# 或者: from _pytest.config.Config import fromdictargs [as 别名]
def remote_initconfig(option_dict, args):
from _pytest.config import Config
option_dict['plugins'].append("no:terminal")
config = Config.fromdictargs(option_dict, args)
config.option.appliances = []
config.args = args
return config
示例2: test_inifilename
# 需要导入模块: from _pytest.config import Config [as 别名]
# 或者: from _pytest.config.Config import fromdictargs [as 别名]
def test_inifilename(self, tmpdir):
tmpdir.join("foo/bar.ini").ensure().write(_pytest._code.Source("""
[pytest]
name = value
"""))
from _pytest.config import Config
inifile = '../../foo/bar.ini'
option_dict = {
'inifilename': inifile,
'capture': 'no',
}
cwd = tmpdir.join('a/b')
cwd.join('pytest.ini').ensure().write(_pytest._code.Source("""
[pytest]
name = wrong-value
should_not_be_set = true
"""))
with cwd.ensure(dir=True).as_cwd():
config = Config.fromdictargs(option_dict, ())
assert config.args == [str(cwd)]
assert config.option.inifilename == inifile
assert config.option.capture == 'no'
# this indicates this is the file used for getting configuration values
assert config.inifile == inifile
assert config.inicfg.get('name') == 'value'
assert config.inicfg.get('should_not_be_set') is None
示例3: test_origargs
# 需要导入模块: from _pytest.config import Config [as 别名]
# 或者: from _pytest.config.Config import fromdictargs [as 别名]
def test_origargs(self):
"""Show that fromdictargs can handle args in their "orig" format"""
from _pytest.config import Config
option_dict = {}
args = ['-vvvv', '-s', 'a', 'b']
config = Config.fromdictargs(option_dict, args)
assert config.args == ['a', 'b']
assert config._origargs == args
assert config.option.verbose == 4
assert config.option.capture == 'no'
示例4: remote_initconfig
# 需要导入模块: from _pytest.config import Config [as 别名]
# 或者: from _pytest.config.Config import fromdictargs [as 别名]
def remote_initconfig(option_dict, args):
from _pytest.config import Config
option_dict['plugins'].append("no:terminal")
config = Config.fromdictargs(option_dict, args)
config.option.looponfail = False
config.option.usepdb = False
config.option.dist = "no"
config.option.distload = False
config.option.numprocesses = None
config.args = args
return config
示例5: test_basic_behavior
# 需要导入模块: from _pytest.config import Config [as 别名]
# 或者: from _pytest.config.Config import fromdictargs [as 别名]
def test_basic_behavior(self):
from _pytest.config import Config
option_dict = {"verbose": 444, "foo": "bar", "capture": "no"}
args = ["a", "b"]
config = Config.fromdictargs(option_dict, args)
with pytest.raises(AssertionError):
config.parse(["should refuse to parse again"])
assert config.option.verbose == 444
assert config.option.foo == "bar"
assert config.option.capture == "no"
assert config.args == args
示例6: test_basic_behavior
# 需要导入模块: from _pytest.config import Config [as 别名]
# 或者: from _pytest.config.Config import fromdictargs [as 别名]
def test_basic_behavior(self):
from _pytest.config import Config
option_dict = {
'verbose': 444,
'foo': 'bar',
'capture': 'no',
}
args = ['a', 'b']
config = Config.fromdictargs(option_dict, args)
with pytest.raises(AssertionError):
config.parse(['should refuse to parse again'])
assert config.option.verbose == 444
assert config.option.foo == 'bar'
assert config.option.capture == 'no'
assert config.args == args
示例7: init_slave_session
# 需要导入模块: from _pytest.config import Config [as 别名]
# 或者: from _pytest.config.Config import fromdictargs [as 别名]
def init_slave_session(channel, args, option_dict):
import os, sys
outchannel = channel.gateway.newchannel()
sys.stdout = sys.stderr = outchannel.makefile('w')
channel.send(outchannel)
# prune sys.path to not contain relative paths
newpaths = []
for p in sys.path:
if p:
if not os.path.isabs(p):
p = os.path.abspath(p)
newpaths.append(p)
sys.path[:] = newpaths
#fullwidth, hasmarkup = channel.receive()
from _pytest.config import Config
config = Config.fromdictargs(option_dict, list(args))
config.args = args
from xdist.looponfail import SlaveFailSession
SlaveFailSession(config, channel).main()
示例8: test_inifilename
# 需要导入模块: from _pytest.config import Config [as 别名]
# 或者: from _pytest.config.Config import fromdictargs [as 别名]
def test_inifilename(self, tmpdir):
tmpdir.join("foo/bar.ini").ensure().write(
_pytest._code.Source(
"""
[pytest]
name = value
"""
)
)
from _pytest.config import Config
inifile = "../../foo/bar.ini"
option_dict = {"inifilename": inifile, "capture": "no"}
cwd = tmpdir.join("a/b")
cwd.join("pytest.ini").ensure().write(
_pytest._code.Source(
"""
[pytest]
name = wrong-value
should_not_be_set = true
"""
)
)
with cwd.ensure(dir=True).as_cwd():
config = Config.fromdictargs(option_dict, ())
assert config.args == [str(cwd)]
assert config.option.inifilename == inifile
assert config.option.capture == "no"
# this indicates this is the file used for getting configuration values
assert config.inifile == inifile
assert config.inicfg.get("name") == "value"
assert config.inicfg.get("should_not_be_set") is None