Test fixtures provide a fixed baseline to enable us to reliably and repeatedly execute tests. Pytest makes it easy to declare a test fixture function by marking a function with the @pytest.fixture decorator. Then, whenever we use the fixture function name as an argument in a test function declaration, pytest will make the fixture function provide the fixture object. Now we will create the following two pytest fixture functions, which we will use in future test functions:
- application: This test fixture function will perform the necessary setup tasks to create the Flask test app with the appropriate testing configuration and create all the necessary tables in the test database. The fixture will launch the test execution and when the test finishes, the fixture will perform the necessary teardown tasks...