flask入门教程第9章测试报错RuntimeError: Working outside of application context?

第九章测试代码编写测试代码时报错RuntimeError: Working outside of application context。检查过语法核对代码似乎也没啥问题,尝试过把类注释掉,import语句后直接print(db.create_all()),仍旧报错RuntimeError: Working outside of application context?
请问这是咋回事呢?看到报错信息说似乎要在视图函数内部相关代码处添加with app.app_context()?

报错信息: