You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
attributes can't be added via record_xml_attribute to the JUnit XML #8662
# Filter out attributes not permitted by this test family.# Including custom attributes because they are not valid here.temp_attrs= {}
forkeyinself.attrs.keys():
ifkeyinfamilies[self.family]["testcase"]:
temp_attrs[key] =self.attrs[key]
self.attrs=temp_attrs
λ pytest .tmp\test_xml.py --junitxml=.tmp\foo.xml --no-header
======================== test session starts ========================
collected 1 item
.tmp\test_xml.py . [100%]
========================= warnings summary ==========================
test_xml.py::TestClass::test_foo
test_xml.py:2: PytestExperimentalApiWarning: record_xml_attribute is an experimental feature
def test_foo(self, record_xml_attribute):
test_xml.py::TestClass::test_foo
test_xml.py:2: PytestWarning: record_xml_attribute is incompatible with junit_family 'xunit2' (use 'legacy' or 'xunit1')
def test_foo(self, record_xml_attribute):
-- Docs: https://docs.pytest.org/en/stable/warnings.html
-------- generated xml file: e:\projects\pytest\.tmp\foo.xml --------
=================== 1 passed, 2 warnings in 0.01s ===================
The 2nd warning is the important one: record_xml_attribute is incompatible with junit_family 'xunit2' (use 'legacy' or 'xunit1'). The default junit_family is indeed xunit2 in recent pytest versions.
Activity
Zac-HD commentedon May 12, 2021
(edited just to add syntax highlighting 🙂)
gs202 commentedon May 12, 2021
It looks like the issue is here
All custom attributes are filtered out
nicoddemus commentedon May 15, 2021
Hi @gs202,
When I execute your example, I get:
The 2nd warning is the important one:
record_xml_attribute is incompatible with junit_family 'xunit2' (use 'legacy' or 'xunit1'). The defaultjunit_familyis indeedxunit2in recent pytest versions.Running:
Then I can see
assertionsin the generated XML file.So everything is working as it should.
Hope this helps!
gs202 commentedon May 18, 2021
Thanks @nicoddemus this indeed solved my issue
I hope that issue #8654 will be resolved soon as well :)