當前位置: 首頁>>代碼示例>>Python>>正文


Python config.Config類代碼示例

本文整理匯總了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
開發者ID:RonnyPfannschmidt,項目名稱:pytest,代碼行數:30,代碼來源:test_config.py

示例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
開發者ID:jkrocil,項目名稱:cfme_tests,代碼行數:7,代碼來源:remote.py

示例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'
開發者ID:RonnyPfannschmidt,項目名稱:pytest,代碼行數:11,代碼來源:test_config.py

示例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
開發者ID:epeden,項目名稱:pytest-xdist,代碼行數:11,代碼來源:remote.py

示例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
開發者ID:kalekundert,項目名稱:pytest,代碼行數:13,代碼來源:test_config.py

示例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
開發者ID:RonnyPfannschmidt,項目名稱:pytest,代碼行數:16,代碼來源:test_config.py

示例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()
開發者ID:rdebliek,項目名稱:oscar,代碼行數:20,代碼來源:looponfail.py

示例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
開發者ID:kalekundert,項目名稱:pytest,代碼行數:36,代碼來源:test_config.py

示例9: pytest_configure

def pytest_configure(config: Config):
    if config.getoption('--report-surefire'):
        plugin = SurefireRESTReporter(config)
        config.pluginmanager.register(plugin, 'surefirereporter')
開發者ID:Scalr,項目名稱:revizor-tests,代碼行數:4,代碼來源:surefire.py


注:本文中的_pytest.config.Config類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。