-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Description
I would like to see pytestmark etc. fixtures be made available to tests.
The use case is:
You have a production database or other "important stuff" that you don't want tests to ever touch, so you write a fixture for your integration tests that ensures this. Using pytestmark, etc. is a good way to ensure that the fixture is always applied and you don't accidentally write a new test that touches your untouchables.
But the tests occasionally need access to the fixture. An example would be a test that looks for a log message when the database can't be accessed, as might be setup by a mock database connector. The test would want to access the mock_db_connector fixture and do:
mock_db_connector.side_effect = mydb.exceptions.ConnectionFailedError()
This would cause the connection to the database to fail, which is the condition the integration test is looking for.