jldupont
jldupont

Reputation: 96796

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.

Upvotes: 1

Views: 567

Answers (1)

gold_cy
gold_cy

Reputation: 14226

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.

Upvotes: 3

Related Questions