本文整理汇总了Python中_pytest.config.Config类的典型用法代码示例。如果您正苦于以下问题:Python Config类的具体用法?Python Config怎么用?Python Config使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Config类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_inifilename
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
示例2: remote_initconfig
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
示例3: test_origargs
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
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
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
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
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
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
示例9: pytest_configure
def pytest_configure(config: Config):
if config.getoption('--report-surefire'):
plugin = SurefireRESTReporter(config)
config.pluginmanager.register(plugin, 'surefirereporter')