What is "client" in every test function?

All test methods must receive client as an argument,
otherwise the database variable won't be configured correctly

At the beginning of every test file we have the above.
Can anyone explain in more detail what it means.

  1. What database variable is it refering to? I don’t see any database variable. These test files are just importing and running functions we implemented in db.py
  2. What does configure correctly mean? Whats the expected, and actual behaviour? Is there some undesired default config going on when the test methods don’t receive client argument?
  3. Where did this client come from? I thought it was a fixture, but i can’t find any fixture named client. There was only def app(): under @pytest.fixture

Hey @Han_N_A,

Kindly ignore it. It is the nature of the tests that they are designed in such a way that client is required as an argument in those methods. The instructions are only meant to let the learners know that they are not supposed to remove the client argument from the method. You don’t need to in fact do anything in the test methods and only need to complete the implementations in db.py as being asked in the different labs.


I’m trying to see what coding patterns are transferrable to other projects.
Can I get confirmation that this client argument is not a pytest fixture, and is there specifically for the integration tests on the /status page?
Is there some code refering to client from files that mongo team wrote, that students have no access to, and that this pattern is specifically written only for this course, and is not something general to pytest? Meaning if i test my own mongo project, there won’t be any reason to include it?

this client fixture is not part of pytest but is coming from pytest-flask to test a flask application. check the link to it, and check that page for more about pytest-flask

client-application-test-client — pytest-flask documentation


This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.