Skip to content

Support access to autouse/pytestmark/etc. fixtures #6565

@kpinc

Description

@kpinc

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: needs informationreporter needs to provide more information; can be closed after 2 or more weeks of inactivitytype: questiongeneral question, might be closed after 2 weeks of inactivity

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions