pytest: environment variable to specify pytest.ini location
Asked Answered
R

1

10

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?

Rangefinder answered 6/7, 2017 at 21:16 Comment(4)
Why can't you just run pytest from the volume containing your project?Avalos
because the volume also has the pytest.ini I have on my project root. I would have to run it with pytest -c /location/of/new/pytest.iniRangefinder
What pytest.ini file do you want to use when running pytest inside the container, the one in your project directory or another one? If another one, you should make that clearer in the question.Avalos
The documentation does not show using a variable for this. docs.pytest.org/en/latest/customize.htmlSumac
H
11

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.

Hairston answered 6/7, 2017 at 21:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.