Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

force pytest.main() to use a different pytest.ini

Tags:

python

pytest

Is there a way to point pytest at a differnt pytest.ini file?

The application I am working on has one pytest.ini file that is used for running unittests when it spins up, and I do not want to modify that file.

I do however want to point pytest at a different file when running my automation tests via pytest.main()

pytest.main(['-p', 'no:django', '-v', '--json-report', '-m', test_marker])

Is there a way to tell pytest to use a pytest.ini file from another location?

like image 443
Lombax Avatar asked Oct 19 '25 02:10

Lombax


1 Answers

$ pytest --help | grep -F config
  -c file               load configuration from `file` instead of trying to
                        locate one of the implicit configuration files.

That is,

pytest.main(['-c', 'pytest-alt.ini'])
like image 174
phd Avatar answered Oct 22 '25 05:10

phd



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!