当前位置: 首页>>代码示例>>Python>>正文


Python config.Config类代码示例

本文整理汇总了Python中etcaetera.config.Config的典型用法代码示例。如果您正苦于以下问题:Python Config类的具体用法?Python Config怎么用?Python Config使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Config类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_adapters_setter_raises_if_defaults_is_not_first

    def test_adapters_setter_raises_if_defaults_is_not_first(self):
        defaults_adapter = Defaults({"abc": "123"})
        env_adapter = Env()
        config = Config()

        with pytest.raises(ValueError):
            # defaults_adapter should always be first
            config.adapters = [env_adapter, defaults_adapter]
开发者ID:ramnes,项目名称:etcaetera,代码行数:8,代码来源:test_config.py

示例2: test_adapters_setter_raises_if_overrides_is_not_last

    def test_adapters_setter_raises_if_overrides_is_not_last(self):
        overrides_adapter = Overrides({"abc": "123"})
        env_adapter = Env()
        config = Config()

        with pytest.raises(ValueError):
            # overrides_adapter should always be last 
            config.adapters = [overrides_adapter, env_adapter]
开发者ID:ramnes,项目名称:etcaetera,代码行数:8,代码来源:test_config.py

示例3: test_register_a_non_special_adapter_with_empty_adapters

    def test_register_a_non_special_adapter_with_empty_adapters(self):
        env_adapter = Env()
        config = Config()

        config.register(env_adapter)
        
        assert len(config.adapters) == 1
        assert config.adapters[0] == env_adapter
开发者ID:ramnes,项目名称:etcaetera,代码行数:8,代码来源:test_config.py

示例4: test_register_a_second_overrides_replaces_existing_one

    def test_register_a_second_overrides_replaces_existing_one(self):
        env_adapter = Env()
        overrides_adapter = Overrides({"abc": "123"})
        config = Config()
        config.adapters = [env_adapter, overrides_adapter]

        new_overrides = Overrides({"easy as": "do re mi"})
        config.register(new_overrides)
        assert config.overrides == new_overrides
开发者ID:ramnes,项目名称:etcaetera,代码行数:9,代码来源:test_config.py

示例5: test_register_sets_overrides_adapter_as_last_with_empty_adapters

    def test_register_sets_overrides_adapter_as_last_with_empty_adapters(self):
        overrides_adapter = Overrides({"abc": "123"})
        config = Config()

        config.adapters = []
        config.register(overrides_adapter)

        assert len(config.adapters) == 1
        assert config.adapters[0] == overrides_adapter 
开发者ID:ramnes,项目名称:etcaetera,代码行数:9,代码来源:test_config.py

示例6: test_register_a_second_defaults_raises

    def test_register_a_second_defaults_raises(self):
        env_adapter = Env()
        defaults_adapter = Defaults({"abc": "123"})
        config = Config()

        config.adapters = [defaults_adapter, env_adapter]

        with pytest.raises(ValueError):
            config.register(defaults_adapter)
开发者ID:alixz,项目名称:etcaetera,代码行数:9,代码来源:test_config.py

示例7: test_register_sets_defaults_adapter_as_first_with_empty_adapters

    def test_register_sets_defaults_adapter_as_first_with_empty_adapters(self):
        defaults_adapter = Defaults({"abc": "123"})
        config = Config()

        config.adapters = []
        config.register(defaults_adapter)

        assert len(config.adapters) == 1
        assert config.adapters[0] == defaults_adapter
开发者ID:ramnes,项目名称:etcaetera,代码行数:9,代码来源:test_config.py

示例8: test_load_method_loads_values_from_adapters

    def test_load_method_loads_values_from_adapters(self):
        defaults = Defaults({"abc": "123"})
        config = Config()

        config.register(defaults)
        config.load()

        assert "ABC" in config
        assert config["ABC"] == "123"
开发者ID:ramnes,项目名称:etcaetera,代码行数:9,代码来源:test_config.py

示例9: test_register_a_second_defaults_overrides_existing_one

    def test_register_a_second_defaults_overrides_existing_one(self):
        env_adapter = Env()
        defaults_adapter = Defaults({"abc": "123"})
        config = Config()
        config.adapters = [defaults_adapter, env_adapter]

        new_defaults = Defaults({"easy as": "do re mi"})
        config.register(new_defaults)
        assert config.defaults == new_defaults
开发者ID:ramnes,项目名称:etcaetera,代码行数:9,代码来源:test_config.py

示例10: test_register_sets_overrides_adapter_as_last_with_existing_adapters

    def test_register_sets_overrides_adapter_as_last_with_existing_adapters(self):
        env_adapter = Env()
        overrides_adapter = Overrides({"abc": "123"})
        config = Config()

        config.adapters = [env_adapter]
        config.register(overrides_adapter)

        assert config.adapters[0] == env_adapter
        assert config.adapters[1] == overrides_adapter 
开发者ID:ramnes,项目名称:etcaetera,代码行数:10,代码来源:test_config.py

示例11: test_add_subconfig_adds_config_as_attribute

    def test_add_subconfig_adds_config_as_attribute(self):
        main_config = Config()
        sub_config = Config({"abc": "123"})

        main_config.add_subconfig('mysubconfig', sub_config)
        assert 'mysubconfig' in main_config._subconfigs
        assert main_config._subconfigs['mysubconfig'] == sub_config

        assert hasattr(main_config, 'mysubconfig')
        assert main_config.mysubconfig == sub_config
开发者ID:bitprophet,项目名称:etcaetera,代码行数:10,代码来源:test_config.py

示例12: test_register_sets_defaults_adapter_as_first_with_existing_adapters

    def test_register_sets_defaults_adapter_as_first_with_existing_adapters(self):
        env_adapter = Env()
        defaults_adapter = Defaults({"abc": "123"})
        config = Config()

        config.adapters = [env_adapter]
        config.register(defaults_adapter)

        assert config.adapters[0] == defaults_adapter
        assert config.adapters[1] == env_adapter
开发者ID:ramnes,项目名称:etcaetera,代码行数:10,代码来源:test_config.py

示例13: test_register_multiple_adapters

    def test_register_multiple_adapters(self):
        config = Config()
        defaults_adapter = Defaults()
        env_adapter = Env()
        file_adapter = File('/tmp/test')
        config.register(defaults_adapter, env_adapter, file_adapter)

        assert len(config.adapters) == 3
        assert config.adapters[0] == defaults_adapter
        assert config.adapters[1] == env_adapter
        assert config.adapters[2] == file_adapter
开发者ID:ramnes,项目名称:etcaetera,代码行数:11,代码来源:test_config.py

示例14: test_register_non_special_adapters_protects_order

    def test_register_non_special_adapters_protects_order(self):
        env_adapter = Env()
        file_adapter = File('/tmp/test')
        config = Config()

        config.register(env_adapter)
        config.register(file_adapter)
        
        assert len(config.adapters) == 2
        assert config.adapters[0] == env_adapter
        assert config.adapters[1] == file_adapter
开发者ID:ramnes,项目名称:etcaetera,代码行数:11,代码来源:test_config.py

示例15: test_load_passes_its_keys_to_env_loading

    def test_load_passes_its_keys_to_env_loading(self):
        env = Env(keys=["USER", "PATH"])
        config = Config({"PATH":None})

        config.register(env)
        config.load()

        assert "USER" in config
        assert "PATH" in config
        assert config["USER"] == os.environ["USER"]
        assert config["PATH"] == os.environ["PATH"]
开发者ID:ramnes,项目名称:etcaetera,代码行数:11,代码来源:test_config.py


注:本文中的etcaetera.config.Config类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。