4
4

2 回答 2

1

好吧,我想我明白了。阅读Martjin 在这里的答案,我能够通过执行以下操作使其工作:

response = client.post('/models', data=json.dumps(job), headers=headers)
于 2017-06-15T13:48:07.303 回答
0
@pytest.fixture
def app():
    app = App(__name__, specification_dir=SWAGGER_PATH)
    app.app.json_encoder = JSONEncoder
    app.add_api("swagger.yaml")
    app_client = app.app.test_client()
    return app_client


def test_post_foo(app) -> None:
    """
    :expect:201
    """

    response = app.post("/api/all", 
    content_type='application/json',
    data=json.dumps(foo_data))
    assert response.status_code == 201

于 2020-04-10T12:41:46.930 回答