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


Python app.config方法代码示例

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


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

示例1: test_config_from_envvar

# 需要导入模块: from config_package_app import app [as 别名]
# 或者: from config_package_app.app import config [as 别名]
def test_config_from_envvar(self):
        env = os.environ
        try:
            os.environ = {}
            app = flask.Flask(__name__)
            try:
                app.config.from_envvar('FOO_SETTINGS')
            except RuntimeError as e:
                self.assert_true("'FOO_SETTINGS' is not set" in str(e))
            else:
                self.assert_true(0, 'expected exception')
            self.assert_false(app.config.from_envvar('FOO_SETTINGS', silent=True))

            os.environ = {'FOO_SETTINGS': __file__.rsplit('.', 1)[0] + '.py'}
            self.assert_true(app.config.from_envvar('FOO_SETTINGS'))
            self.common_object_test(app)
        finally:
            os.environ = env 
开发者ID:sugarguo,项目名称:Flask_Blog,代码行数:20,代码来源:config.py

示例2: test_config_from_envvar_missing

# 需要导入模块: from config_package_app import app [as 别名]
# 或者: from config_package_app.app import config [as 别名]
def test_config_from_envvar_missing(self):
        env = os.environ
        try:
            os.environ = {'FOO_SETTINGS': 'missing.cfg'}
            try:
                app = flask.Flask(__name__)
                app.config.from_envvar('FOO_SETTINGS')
            except IOError as e:
                msg = str(e)
                self.assert_true(msg.startswith('[Errno 2] Unable to load configuration '
                                            'file (No such file or directory):'))
                self.assert_true(msg.endswith("missing.cfg'"))
            else:
                self.fail('expected IOError')
            self.assertFalse(app.config.from_envvar('FOO_SETTINGS', silent=True))
        finally:
            os.environ = env 
开发者ID:rui7157,项目名称:Flask-NvRay-Blog,代码行数:19,代码来源:config.py

示例3: common_object_test

# 需要导入模块: from config_package_app import app [as 别名]
# 或者: from config_package_app.app import config [as 别名]
def common_object_test(self, app):
        self.assert_equal(app.secret_key, 'devkey')
        self.assert_equal(app.config['TEST_KEY'], 'foo')
        self.assert_not_in('ConfigTestCase', app.config) 
开发者ID:sugarguo,项目名称:Flask_Blog,代码行数:6,代码来源:config.py

示例4: test_config_from_file

# 需要导入模块: from config_package_app import app [as 别名]
# 或者: from config_package_app.app import config [as 别名]
def test_config_from_file(self):
        app = flask.Flask(__name__)
        app.config.from_pyfile(__file__.rsplit('.', 1)[0] + '.py')
        self.common_object_test(app) 
开发者ID:sugarguo,项目名称:Flask_Blog,代码行数:6,代码来源:config.py

示例5: test_config_from_object

# 需要导入模块: from config_package_app import app [as 别名]
# 或者: from config_package_app.app import config [as 别名]
def test_config_from_object(self):
        app = flask.Flask(__name__)
        app.config.from_object(__name__)
        self.common_object_test(app) 
开发者ID:sugarguo,项目名称:Flask_Blog,代码行数:6,代码来源:config.py

示例6: test_config_from_class

# 需要导入模块: from config_package_app import app [as 别名]
# 或者: from config_package_app.app import config [as 别名]
def test_config_from_class(self):
        class Base(object):
            TEST_KEY = 'foo'
        class Test(Base):
            SECRET_KEY = 'devkey'
        app = flask.Flask(__name__)
        app.config.from_object(Test)
        self.common_object_test(app) 
开发者ID:sugarguo,项目名称:Flask_Blog,代码行数:10,代码来源:config.py

示例7: test_config_missing

# 需要导入模块: from config_package_app import app [as 别名]
# 或者: from config_package_app.app import config [as 别名]
def test_config_missing(self):
        app = flask.Flask(__name__)
        try:
            app.config.from_pyfile('missing.cfg')
        except IOError as e:
            msg = str(e)
            self.assert_true(msg.startswith('[Errno 2] Unable to load configuration '
                                        'file (No such file or directory):'))
            self.assert_true(msg.endswith("missing.cfg'"))
        else:
            self.assert_true(0, 'expected config')
        self.assert_false(app.config.from_pyfile('missing.cfg', silent=True)) 
开发者ID:sugarguo,项目名称:Flask_Blog,代码行数:14,代码来源:config.py

示例8: test_session_lifetime

# 需要导入模块: from config_package_app import app [as 别名]
# 或者: from config_package_app.app import config [as 别名]
def test_session_lifetime(self):
        app = flask.Flask(__name__)
        app.config['PERMANENT_SESSION_LIFETIME'] = 42
        self.assert_equal(app.permanent_session_lifetime.seconds, 42) 
开发者ID:sugarguo,项目名称:Flask_Blog,代码行数:6,代码来源:config.py


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