How can I set an environment variable with the location of the pytest.ini
, tox.ini
or setup.cfg
for running pytest
by default?
I created a docker container with a volume pointing to my project directory, so every change I make is also visible inside the docker container. The problem is that I have a pytest.ini
file on my project root which won't apply to the docker container.
So I want to set an environment variable inside the docker container to specify where to look for the pytest configuration. Does anyone have any idea how could I do that?
Users can customize some pytest behavior using a configuration file called pytest. ini . This file is usually placed at the root of the repository and contains a number of configuration values that are applied to all test runs for that project.
Using pytest-env pluginWe can use this plugin to set environment variables that don't really matter to the function implementations. Install pytest-env plugin using pip install pytest-env .
This is a pytest plugin that enables you to set environment variables in a pytest. ini or pyproject. toml file.
The pytestconfig fixture is a shortcut to request. config, and is sometimes referred to in the pytest documentation as “the pytest config object.” To see how pytestconfig works, you'll look at how to add a custom command-line option and read the option value from within a test.
There is no way to do that. You can use a different pytest configuration using pytest -c
but tox.ini
and setup.cfg
must reside in the top-level directory of your package, next to setup.py
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With