Flask Documentation (1.1.x)
Registering Filters Context Processors Testing Flask Applications The Application The Testing Skeleton The First Test Logging In and Out Test Adding Messages Other Testing Tricks Faking Resources and Context Context Keeping the Context Around Accessing and Modifying Sessions Testing JSON APIs Testing CLI Commands Application Errors Error Logging Tools Error handlers Logging Debugging Application Errors When on http://127.0.0.1:5000/ This launches a very simple builtin server, which is good enough for testing but probably not what you want to use in production. For deployment options see Deployment Options0 码力 | 428 页 | 895.98 KB | 1 年前3Flask Documentation (1.1.x)
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 1.7 Testing Flask Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . on http://127.0.0.1:5000/ This launches a very simple builtin server, which is good enough for testing but probably not what you want to use in production. For deployment options see Deployment Options Basically you can completely ignore that this is the case unless you are doing something like unit testing. You will notice that code which depends on a request object will suddenly break because there is0 码力 | 291 页 | 1.25 MB | 1 年前3Flask入门教程
ttest.TestCase): def setUp(self): # 更新配置 app.config.update( TESTING=True, SQLALCHEMY_DATABASE_URI='sqlite:///:memory:' ) # 创建数据库和表 测试程序是否处于测试模式 def test_app_is_testing(self): self.assertTrue(app.config['TESTING']) 第 9 章:测试 92 某些配置,在开发和测试时通常需要使用不同的值。在 setUp() 方法中,我们更 新了两个配置变量的值,首先将 TESTING 设为 True 来开启测试模式,这样在 出错时不会输出多余信息;然后将0 码力 | 127 页 | 7.62 MB | 1 年前3
共 3 条
- 1