本文整理匯總了Python中webapp2.Config類的典型用法代碼示例。如果您正苦於以下問題:Python Config類的具體用法?Python Config怎麽用?Python Config使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Config類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_get_existing_keys_from_default
def test_get_existing_keys_from_default(self):
config = Config({}, {'foo': {
'bar': 'baz',
'doo': 'ding',
}})
self.assertEqual(config.get_config('foo', 'bar'), 'baz')
self.assertEqual(config.get_config('foo', 'doo'), 'ding')
示例2: test_get_existing_keys_from_default
def test_get_existing_keys_from_default(self):
config = Config({}, {'foo': {
'bar': 'baz',
'doo': 'ding',
}})
assert config.get('foo', 'bar') == 'baz'
assert config.get('foo', 'doo') == 'ding'
示例3: test_default_config
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.get_or_load('resources.template', 'templates_dir') == template_config['templates_dir']
assert config.get_or_load('resources.i18n', 'locale') == i18n_config['locale']
assert config.get_or_load('resources.i18n', 'timezone') == i18n_config['timezone']
示例4: test_override_config2
def test_override_config2(self):
config = Config({
'resources.i18n': {
'timezone': 'America/Sao_Paulo',
},
})
self.assertEqual(config.get_config('resources.i18n', 'locale'), 'en_US')
self.assertEqual(config.get_config('resources.i18n', 'timezone'), 'America/Sao_Paulo')
示例5: test_default_config
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
self.assertEqual(config.get_config('resources.template', 'templates_dir'), template_config['templates_dir'])
self.assertEqual(config.get_config('resources.i18n', 'locale'), i18n_config['locale'])
self.assertEqual(config.get_config('resources.i18n', 'timezone'), i18n_config['timezone'])
示例6: test_override_config2
def test_override_config2(self):
config = Config({
'resources.i18n': {
'timezone': 'America/Sao_Paulo',
},
})
assert config.get_or_load('resources.i18n', 'locale') == 'en_US'
assert config.get_or_load('resources.i18n', 'timezone') == 'America/Sao_Paulo'
示例7: test_default_config_with_non_existing_key
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.get_or_load('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.get_or_load('resources.i18n', 'i_dont_exist', 'foo') == 'foo'
示例8: test_get_dict_existing_keys
def test_get_dict_existing_keys(self):
config = Config({'foo': {
'bar': 'baz',
'doo': 'ding',
}})
self.assertEqual(config.get_config('foo'), {
'bar': 'baz',
'doo': 'ding',
})
示例9: test_get_dict_existing_keys
def test_get_dict_existing_keys(self):
config = Config({'foo': {
'bar': 'baz',
'doo': 'ding',
}})
assert config.get('foo') == {
'bar': 'baz',
'doo': 'ding',
}
示例10: test_setdefault
def test_setdefault(self):
config = Config()
self.assertRaises(KeyError, config.get_config, 'foo')
config.setdefault('foo', {
'bar': 'baz',
'doo': 'ding',
})
self.assertEqual(config.get_config('foo', 'bar'), 'baz')
self.assertEqual(config.get_config('foo', 'doo'), 'ding')
示例11: test_setdefault
def test_setdefault(self):
config = Config()
assert config.get('foo') is None
config.setdefault('foo', {
'bar': 'baz',
'doo': 'ding',
})
assert config.get('foo', 'bar') == 'baz'
assert config.get('foo', 'doo') == 'ding'
示例12: test_get
def test_get(self):
config = Config({'foo': {
'bar': 'baz',
'doo': 'ding',
}})
self.assertEqual(config.get('foo'), {
'bar': 'baz',
'doo': 'ding',
})
self.assertEqual(config.get('bar'), {})
示例13: test_update
def test_update(self):
config = Config({'foo': {
'bar': 'baz',
'doo': 'ding',
}})
self.assertEqual(config.get_config('foo', 'bar'), 'baz')
self.assertEqual(config.get_config('foo', 'doo'), 'ding')
config.update('foo', {'bar': 'other'})
self.assertEqual(config.get_config('foo', 'bar'), 'other')
self.assertEqual(config.get_config('foo', 'doo'), 'ding')
示例14: test_update
def test_update(self):
config = Config({'foo': {
'bar': 'baz',
'doo': 'ding',
}})
assert config.get('foo', 'bar') == 'baz'
assert config.get('foo', 'doo') == 'ding'
config.update('foo', {'bar': 'other'})
assert config.get('foo', 'bar') == 'other'
assert config.get('foo', 'doo') == 'ding'
示例15: test_override_config
def test_override_config(self):
config = Config({
'resources.template': {
'templates_dir': 'apps/templates'
},
'resources.i18n': {
'locale': 'pt_BR',
'timezone': 'America/Sao_Paulo',
},
})
self.assertEqual(config.get_config('resources.template', 'templates_dir'), 'apps/templates')
self.assertEqual(config.get_config('resources.i18n', 'locale'), 'pt_BR')
self.assertEqual(config.get_config('resources.i18n', 'timezone'), 'America/Sao_Paulo')