本文整理汇总了Python中everett.manager.ConfigManager.basic_config方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigManager.basic_config方法的具体用法?Python ConfigManager.basic_config怎么用?Python ConfigManager.basic_config使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类everett.manager.ConfigManager
的用法示例。
在下文中一共展示了ConfigManager.basic_config方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_nested_options
# 需要导入模块: from everett.manager import ConfigManager [as 别名]
# 或者: from everett.manager.ConfigManager import basic_config [as 别名]
def test_nested_options():
"""Verify nested BoundOptions works."""
config = ConfigManager.from_dict({})
class Foo(RequiredConfigMixin):
required_config = ConfigOptions()
required_config.add_option(
'option1',
default='opt1default',
parser=str
)
class Bar(RequiredConfigMixin):
required_config = ConfigOptions()
required_config.add_option(
'option2',
default='opt2default',
parser=str
)
config = ConfigManager.basic_config()
config = config.with_options(Foo)
config = config.with_options(Bar)
assert config('option2') == 'opt2default'
with pytest.raises(ConfigurationError):
config('option1')
示例2: test_basic_config
# 需要导入模块: from everett.manager import ConfigManager [as 别名]
# 或者: from everett.manager.ConfigManager import basic_config [as 别名]
def test_basic_config(datadir):
os.environ['EVERETT_BASIC_CONFIG_TEST'] = 'foo'
env_filename = os.path.join(datadir, '.env')
config = ConfigManager.basic_config(env_filename)
# This doesn't exist in either the environment or the env file
assert config('FOO', raise_error=False) is NO_VALUE
# This exists in the environment
assert config('EVERETT_BASIC_CONFIG_TEST') == 'foo'
# This exists in the env file
assert config('LOGLEVEL') == 'walter'