简体   繁体   中英

Flask: injection of the "client" parameter using pytest fixture

I just can't figure out how pytest determines the parameter "client" in the Flask test suite located in this file .

class SwaggerTest(object):
    def test_specs_endpoint(self, api, client):
        data = client.get_specs("")
        assert data["swagger"] == "2.0"
        assert data["basePath"] == "/"
        assert data["produces"] == ["application/json"]
        assert data["consumes"] == ["application/json"]
        assert data["paths"] == {}
        assert "info" in data

I've looked in the conftest.py file in the same directory but there is no definition of a fixture for "client".

Thanks for your help.

When I see a fixture being used my immediate reaction like you, is to check the conftest.py file. Since it is not defined there, my next thought is to check the testing requirements which leads me to this line . After finding the documentation for pytest-flask we can see that this fixture, client , is defined as a fixture within that library.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM