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


Python Config.get_or_load方法代码示例

本文整理汇总了Python中webapp2.Config.get_or_load方法的典型用法代码示例。如果您正苦于以下问题:Python Config.get_or_load方法的具体用法?Python Config.get_or_load怎么用?Python Config.get_or_load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在webapp2.Config的用法示例。


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

示例1: test_override_config2

# 需要导入模块: from webapp2 import Config [as 别名]
# 或者: from webapp2.Config import get_or_load [as 别名]
    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'
开发者ID:strogo,项目名称:webapp-improved,代码行数:11,代码来源:test_config.py

示例2: test_default_config

# 需要导入模块: from webapp2 import Config [as 别名]
# 或者: from webapp2.Config import get_or_load [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.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']
开发者ID:strogo,项目名称:webapp-improved,代码行数:11,代码来源:test_config.py

示例3: test_default_config_with_non_existing_key

# 需要导入模块: from webapp2 import Config [as 别名]
# 或者: from webapp2.Config import get_or_load [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.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'
开发者ID:strogo,项目名称:webapp-improved,代码行数:12,代码来源:test_config.py

示例4: test_override_config

# 需要导入模块: from webapp2 import Config [as 别名]
# 或者: from webapp2.Config import get_or_load [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.get_or_load('resources.template', 'templates_dir') == 'apps/templates'
        assert config.get_or_load('resources.i18n', 'locale') == 'pt_BR'
        assert config.get_or_load('resources.i18n', 'timezone') == 'America/Sao_Paulo'
开发者ID:strogo,项目名称:webapp-improved,代码行数:16,代码来源:test_config.py

示例5: test_missing_default_config

# 需要导入模块: from webapp2 import Config [as 别名]
# 或者: from webapp2.Config import get_or_load [as 别名]
 def test_missing_default_config(self):
     config = Config()
     assert config.get_or_load('webapp2', 'foo') == 'baz'
开发者ID:strogo,项目名称:webapp-improved,代码行数:5,代码来源:test_config.py

示例6: test_missing_key

# 需要导入模块: from webapp2 import Config [as 别名]
# 或者: from webapp2.Config import get_or_load [as 别名]
 def test_missing_key(self):
     config = Config()
     config.get_or_load('resources.i18n', 'i_dont_exist')
开发者ID:strogo,项目名称:webapp-improved,代码行数:5,代码来源:test_config.py

示例7: test_missing_module2

# 需要导入模块: from webapp2 import Config [as 别名]
# 或者: from webapp2.Config import get_or_load [as 别名]
 def test_missing_module2(self):
     config = Config()
     assert config.get_or_load('i_dont_exist') == 'baz'
开发者ID:strogo,项目名称:webapp-improved,代码行数:5,代码来源:test_config.py

示例8: test_required_config

# 需要导入模块: from webapp2 import Config [as 别名]
# 或者: from webapp2.Config import get_or_load [as 别名]
 def test_required_config(self):
     config = Config()
     config.get_or_load('resources.i18n', 'required')
开发者ID:strogo,项目名称:webapp-improved,代码行数:5,代码来源:test_config.py

示例9: test_get_with_default_and_module_load

# 需要导入模块: from webapp2 import Config [as 别名]
# 或者: from webapp2.Config import get_or_load [as 别名]
 def test_get_with_default_and_module_load(self):
     config = Config()
     assert config.get_or_load('resources.i18n', 'locale') == 'en_US'
     assert config.get_or_load('resources.i18n', 'locale', 'foo') == 'en_US'
开发者ID:strogo,项目名称:webapp-improved,代码行数:6,代码来源:test_config.py

示例10: test_get_with_default_and_none

# 需要导入模块: from webapp2 import Config [as 别名]
# 或者: from webapp2.Config import get_or_load [as 别名]
    def test_get_with_default_and_none(self):
        config = Config({'foo': {
            'bar': None,
        }})

        assert config.get_or_load('foo', 'bar', 'ooops') is None
开发者ID:strogo,项目名称:webapp-improved,代码行数:8,代码来源:test_config.py

示例11: test_get_with_default

# 需要导入模块: from webapp2 import Config [as 别名]
# 或者: from webapp2.Config import get_or_load [as 别名]
    def test_get_with_default(self):
        config = Config()

        assert config.get_or_load('resources.i18n', 'bar', 'baz') == 'baz'
开发者ID:strogo,项目名称:webapp-improved,代码行数:6,代码来源:test_config.py

示例12: test_get

# 需要导入模块: from webapp2 import Config [as 别名]
# 或者: from webapp2.Config import get_or_load [as 别名]
    def test_get(self):
        config = Config({'foo': {
            'bar': 'baz',
        }})

        assert config.get_or_load('foo', 'bar') == 'baz'
开发者ID:strogo,项目名称:webapp-improved,代码行数:8,代码来源:test_config.py


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