Explicit control of fixtures outside of test run #3817
Labels
topic: fixtures
anything involving fixtures directly or indirectly
type: proposal
proposal for a new feature, often to gather opinions or design the API around the new feature
Pytest fixtures have some really powerful features/properties:
When applying pytest fixtures to various services, this creates a powerful environment for orchestrating those services.
In one of our test suites, we have a more complicated form of the following fixtures:
These fixtures have some really nice properties that I would like to use outside running tests, in other phases of development, such as a development instance of the project under test. It would be nice to be able to start up
api_service
from the command line or Python script, let pytest deal with the dependencies, return control to the user (or sleep) for as long as needed, and clean up after.Most importantly, I'd like to have one place where these fixtures (and their dependencies and startup/teardown logic) are defined, even if they're orchestrated in two environments (running tests and other manual invocations).
The most obvious way I can see to accomplish this would be for pytest to present an interface for 'running' fixtures. Any other approach I consider (using Docker compose, writing another orchestration framework) requires a lot of duplication of the functionality in the fixtures.
Is it possible to do this with the code as currently presented, maybe with just a few lines of code? I found the FixtureManager, which requires a Session which requires a Config object which requires a PluginManager. Can you suggest a way that someone might be able to hack together a fixture runner? Would you consider a feature to expose such functionality more simply, such that one could run something like:
or maybe
The text was updated successfully, but these errors were encountered: