Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pytest: environment variable to specify pytest.ini location

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?

like image 807
eLRuLL Avatar asked Jul 06 '17 21:07

eLRuLL


People also ask

Where do I put pytest ini?

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.

Does pytest set environment variables?

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 .

What is pytest env?

This is a pytest plugin that enables you to set environment variables in a pytest. ini or pyproject. toml file.

What is Pytestconfig?

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.


1 Answers

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.

like image 93
phd Avatar answered Oct 13 '22 04:10

phd