Skip to content

junitxml not picking up user_properties in case of failure in call and error in teardown #6826

Open
@schoi119

Description

@schoi119

JunitXML is not picking up user_properties for the new test case that's created when there is a failure in call and error in teardown.

Here is where it opens a new test case.
https://github.com/pytest-dev/pytest/blob/master/src/_pytest/junitxml.py#L561

We need to do what's done here
https://github.com/pytest-dev/pytest/blob/master/src/_pytest/junitxml.py#L583
after line 561 to add user_properties to close_report as well.

To reproduce the issue

conftest.py

def pytest_collection_modifyitems(items):
    for item in items:
        item.user_properties.append(('key', 'value'))

test_sample.py

import pytest

@pytest.fixture(scope="function")
def some_fixture():
    yield None
    1/0

@pytest.mark.tc91
def test_sample1(some_fixture):
    assert False

run pytest test_sample.py --junitxml=test.xml
You will see that in the first test case in test.xml, there is no property set, where as the second one has it.

I am using pytest 5.3.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    plugin: junitxmlrelated to the junitxml builtin plugintype: bugproblem that needs to be addressed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions