1

Flask-JWT モジュールを使用する Flask アプリケーションで /auth エンドポイントをテストしようとしています。

import json
import pytest

@pytest.mark.usefixtures("testapp")
class TestURLs:

    def test_auth(self, testapp):
        rv = testapp.get('/auth',
            data=json.dumps({'username':'bob', 'password': 'pw'}),
            content_type='application/json')
        ... test assertion ...

/auth エンドポイントは、フラスコ サーバーを実行しているときに完全に機能し、JWT トークンを要求できます。

しかし、テストが実行されると、サーバーからこの応答を受け取ります。

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>404 Not Found</title>
<h1>Not Found</h1>
<p>The requested URL was not found on the server.  If you entered the URL manually please check your spelling and try again.</p>

/auth エンドポイントを認識するようにテスト フィクスチャを構成する方法はありますか?

4

0 に答える 0