Pytest: Can I somehow use multiple "pytest" sections in a single file, or similar?

Created on 2 Jan 2018  路  3Comments  路  Source: pytest-dev/pytest

Hi,

I'm having a specific project that requires a couple (10) different junit reports.

I can call 10 different calls like this:

py.test --junitxml test_json.xml FileDownloaderTestSuite.py -k MyTestGetJson
py.test --junitxml test_xml.xml FileDownloaderTestSuite.py -k MyTestGetXML

...

Which works fine, but for the simplicity and efficiency on Jenkins, I'd like to use pytest.ini.

So I tried:

[pytest]
addopts = 
    -k MyTestGetJson
    --junitxml=test_json.xml

Which works, but now if I add next "[pytest]" section, or multiple -k values it breaks.

not sure if there's a simple way to resolve this usin pytest.ini, or should I default to bash script?

junitxml

Most helpful comment

You should use different ini files and specify it on command line like this:

py.test -c MyTestGetJson.ini
py.test -c MyTestGetXML.ini

-c file load configuration from file instead of trying to
locate one of the implicit configuration files.

All 3 comments

GitMate.io thinks the contributors most likely able to help are @nicoddemus, and @RonnyPfannschmidt.

You should use different ini files and specify it on command line like this:

py.test -c MyTestGetJson.ini
py.test -c MyTestGetXML.ini

-c file load configuration from file instead of trying to
locate one of the implicit configuration files.

You might also want to look into tox as an easy way to have different pytest invocations both locally and on enkins.

Was this page helpful?
0 / 5 - 0 ratings