Label Integration Tests
Let’s learn about how to label integration tests with the pytest library.
Before we move on to implementation, we always test the system to see if it will work with all of its components. To do this, we need to label the integration tests, exclude them by default, and create a way to run them. Since pytest supports labels, called marks, we can use this feature to add a global mark to an entire module.
Update the test cases
Let’s put the following code into the tests/repository/postgres/test_postgresrepo.py
file.
Press + to interact
import pytestpytestmark = pytest.mark.integrationdef test_dummy():pass
The module attribute pytestmark
labels every test in the module with the integration
tag. To verify that this works, we add a test_dummy
test function, which always passes.
Update the pytest
...Access this course and 1400+ top-rated courses and projects.