pytest
pytest copied to clipboard
Provide for an easier way to re-use fixtures or plugins from other conftests
It'd be very helpful to have one canonical way to re-use fixture code between test modules. Right now, I know of 3 ways to do this, each with their own downsides:
- Import the fixture/hook directly -- Results in unused imports, and isn't always clear where the code came from. Easy to break things later when cleaning up unused imports.
- Use
pytest_plugins = 'path.to.conftest'
-- Will result in pytest errors if you run the current module and the module the conftest came from at the same time. Also makes the plugin globally active, which isn't always desired. - Move the code to a common-ancestor -- Can make the fixtures too broadly usable, especially if the test modules aren't relatively close to each other.