Lombax
Lombax

Reputation: 871

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

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?

Upvotes: 4

Views: 1447

Answers (1)

phd
phd

Reputation: 94397

$ 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'])

Upvotes: 9

Related Questions