擅长:python、mysql、java
<p>Flask有一个<a href="http://flask.pocoo.org/docs/latest/appcontext/#creating-an-application-context" rel="noreferrer">Application Context</a>,看起来你需要做如下事情:</p>
<pre><code>def test_connection(self):
with app.app_context():
#test code
</code></pre>
<p>您也可以将<code>app.app_context()</code>调用推送到测试设置方法中。希望这有帮助。</p>