本文整理汇总了Python中webapp2.Config.load_and_get方法的典型用法代码示例。如果您正苦于以下问题:Python Config.load_and_get方法的具体用法?Python Config.load_and_get怎么用?Python Config.load_and_get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类webapp2.Config
的用法示例。
在下文中一共展示了Config.load_and_get方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_override_config2
# 需要导入模块: from webapp2 import Config [as 别名]
# 或者: from webapp2.Config import load_and_get [as 别名]
def test_override_config2(self):
config = Config({
'resources.i18n': {
'timezone': 'America/Sao_Paulo',
},
})
assert config.load_and_get('resources.i18n', 'locale') == 'en_US'
assert config.load_and_get('resources.i18n', 'timezone') == 'America/Sao_Paulo'
示例2: test_default_config
# 需要导入模块: from webapp2 import Config [as 别名]
# 或者: from webapp2.Config import load_and_get [as 别名]
def test_default_config(self):
config = Config()
from resources.template import default_config as template_config
from resources.i18n import default_config as i18n_config
assert config.load_and_get('resources.template', 'templates_dir') == template_config['templates_dir']
assert config.load_and_get('resources.i18n', 'locale') == i18n_config['locale']
assert config.load_and_get('resources.i18n', 'timezone') == i18n_config['timezone']
示例3: test_default_config_with_non_existing_key
# 需要导入模块: from webapp2 import Config [as 别名]
# 或者: from webapp2.Config import load_and_get [as 别名]
def test_default_config_with_non_existing_key(self):
config = Config()
from resources.i18n import default_config as i18n_config
# In the first time the module config will be loaded normally.
assert config.load_and_get('resources.i18n', 'locale') == i18n_config['locale']
# In the second time it won't be loaded, but won't find the value and then use the default.
assert config.load_and_get('resources.i18n', 'i_dont_exist', 'foo') == 'foo'
示例4: test_override_config
# 需要导入模块: from webapp2 import Config [as 别名]
# 或者: from webapp2.Config import load_and_get [as 别名]
def test_override_config(self):
config = Config({
'resources.template': {
'templates_dir': 'apps/templates'
},
'resources.i18n': {
'locale': 'pt_BR',
'timezone': 'America/Sao_Paulo',
},
})
assert config.load_and_get('resources.template', 'templates_dir') == 'apps/templates'
assert config.load_and_get('resources.i18n', 'locale') == 'pt_BR'
assert config.load_and_get('resources.i18n', 'timezone') == 'America/Sao_Paulo'
示例5: test_missing_default_config
# 需要导入模块: from webapp2 import Config [as 别名]
# 或者: from webapp2.Config import load_and_get [as 别名]
def test_missing_default_config(self):
config = Config()
assert config.load_and_get('webapp2', 'foo') == 'baz'
示例6: test_missing_key
# 需要导入模块: from webapp2 import Config [as 别名]
# 或者: from webapp2.Config import load_and_get [as 别名]
def test_missing_key(self):
config = Config()
config.load_and_get('resources.i18n', 'i_dont_exist')
示例7: test_missing_module2
# 需要导入模块: from webapp2 import Config [as 别名]
# 或者: from webapp2.Config import load_and_get [as 别名]
def test_missing_module2(self):
config = Config()
assert config.load_and_get('i_dont_exist') == 'baz'
示例8: test_required_config
# 需要导入模块: from webapp2 import Config [as 别名]
# 或者: from webapp2.Config import load_and_get [as 别名]
def test_required_config(self):
config = Config()
config.load_and_get('resources.i18n', 'required')
示例9: test_get_with_default_and_module_load
# 需要导入模块: from webapp2 import Config [as 别名]
# 或者: from webapp2.Config import load_and_get [as 别名]
def test_get_with_default_and_module_load(self):
config = Config()
assert config.load_and_get('resources.i18n', 'locale') == 'en_US'
assert config.load_and_get('resources.i18n', 'locale', 'foo') == 'en_US'
示例10: test_get_with_default_and_none
# 需要导入模块: from webapp2 import Config [as 别名]
# 或者: from webapp2.Config import load_and_get [as 别名]
def test_get_with_default_and_none(self):
config = Config({'foo': {
'bar': None,
}})
assert config.load_and_get('foo', 'bar', 'ooops') is None
示例11: test_get_with_default
# 需要导入模块: from webapp2 import Config [as 别名]
# 或者: from webapp2.Config import load_and_get [as 别名]
def test_get_with_default(self):
config = Config()
assert config.load_and_get('resources.i18n', 'bar', 'baz') == 'baz'
示例12: test_get
# 需要导入模块: from webapp2 import Config [as 别名]
# 或者: from webapp2.Config import load_and_get [as 别名]
def test_get(self):
config = Config({'foo': {
'bar': 'baz',
}})
assert config.load_and_get('foo', 'bar') == 'baz'