Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pytest --junit-xml has bug on file and classname path reporting #8035

Closed
4 tasks done
rrlamichhane opened this issue Nov 13, 2020 · 2 comments
Closed
4 tasks done

pytest --junit-xml has bug on file and classname path reporting #8035

rrlamichhane opened this issue Nov 13, 2020 · 2 comments
Labels
plugin: junitxml related to the junitxml builtin plugin status: needs information reporter needs to provide more information; can be closed after 2 or more weeks of inactivity topic: config related to config handling, argument parsing and config file type: bug problem that needs to be addressed

Comments

@rrlamichhane
Copy link

rrlamichhane commented Nov 13, 2020

Description:
When I run pytest with a -c option, the junit-xml reports with junit_family=xunit1 doesn't populate the classname and file field with the appropriate full path from root.

e.g.

pytest project/tasks/tests/test_module_a.py
# Example output line of xml report
<testcase classname="test_fsm" file="project/tasks/tests/test_module_a.py" line="72" name="test_something" time="0.004"/>

# Now, running with a "-c" option; please note that even when the default "pytest.ini" is supplied with "-c" argument, the bug persists
pytest -c pytest.ini project/tasks/tests/test_module_a.py
# Example output line of xml report
<testcase classname="test_fsm" file="test_module_a.py" line="72" name="test_something" time="0.004"/>

Pip List:
Attached file.

Versions and plug-ins:

'Python': '3.6.8', 'Platform': 'Linux-4.15.0-1077-aws-x86_64-with-Ubuntu-16.04-xenial'
'Packages': {'pytest': '6.1.1', 'py': '1.9.0', 'pluggy': '0.13.1'}
'Plugins': {'timeout': '1.4.2', 'html': '2.1.1', 'metadata': '1.10.0', 'mock': '3.3.1', 'cov': '2.10.1', 'django': '3.9.0'}
  • a detailed description of the bug or problem you are having
  • output of pip list from the virtual environment you are using
  • pytest and operating system versions
  • minimal example if possible
    pip_list_pytest_bug.txt
@Zac-HD Zac-HD added plugin: junitxml related to the junitxml builtin plugin topic: config related to config handling, argument parsing and config file type: bug problem that needs to be addressed labels Nov 14, 2020
@nicoddemus
Copy link
Member

nicoddemus commented Nov 27, 2020

Hi @ranjan-osaro,

Thanks for the report and sorry for the delay.

I however couldn't reproduce the issue, here's what I have:

junit_c/
    tests/
        test_module.py
pytest.ini    # sets junit_family=xunit1

I get the same results regardless if -c is given:

λ pytest --no-header --junitxml=foo.xml && cat foo.xml
======================================= test session starts =======================================
collected 1 item

tests\test_module.py .                                                                       [100%]

------------------- generated xml file: d:\projects\pytest\.tmp\junit_c\foo.xml -------------------
======================================== 1 passed in 0.03s ========================================
<?xml version="1.0" encoding="utf-8"?><testsuites><testsuite name="pytest" errors="0" failures="0" skipped="0" tests="1" time="0.025" timestamp="2020-11-27T09:22:21.447437" hostname="Neco"><testcase classname="tests.test_module" name="test" file="tests\test_module.py" line="0" time="0.002" /></testsuite></testsuites>
λ pytest -c pytest.ini --no-header --junitxml=foo.xml && cat foo.xml
======================================= test session starts =======================================
collected 1 item

tests\test_module.py .                                                                       [100%]

------------------- generated xml file: d:\projects\pytest\.tmp\junit_c\foo.xml -------------------
======================================== 1 passed in 0.03s ========================================
<?xml version="1.0" encoding="utf-8"?><testsuites><testsuite name="pytest" errors="0" failures="0" skipped="0" tests="1" time="0.029" timestamp="2020-11-27T09:22:44.768536" hostname="Neco"><testcase classname="tests.test_module" name="test" file="tests\test_module.py" line="0" time="0.001" /></testsuite></testsuites>

Both XML files contain the correct path: file="tests\test_module.py".

Could you provide a fully reproducible example?

@nicoddemus nicoddemus added the status: needs information reporter needs to provide more information; can be closed after 2 or more weeks of inactivity label Nov 27, 2020
@Zac-HD
Copy link
Member

Zac-HD commented Feb 1, 2021

I'm closing this issue because we can't fix it without a reproducing example. If anyone can provide a short script that we can run to demonstrate this error, we'll be happy to reopen the issue!

@Zac-HD Zac-HD closed this as completed Feb 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin: junitxml related to the junitxml builtin plugin status: needs information reporter needs to provide more information; can be closed after 2 or more weeks of inactivity topic: config related to config handling, argument parsing and config file type: bug problem that needs to be addressed
Projects
None yet
Development

No branches or pull requests

3 participants