diff --git a/testing/test_junitxml.py b/testing/test_junitxml.py index 1021c728b..2765dfc60 100644 --- a/testing/test_junitxml.py +++ b/testing/test_junitxml.py @@ -980,6 +980,12 @@ def test_record_property_same_name(testdir): @pytest.mark.filterwarnings("default") def test_record_attribute(testdir): + testdir.makeini( + """ + [pytest] + junit_family = xunit1 + """ + ) testdir.makepyfile( """ import pytest @@ -1001,6 +1007,38 @@ def test_record_attribute(testdir): ) +@pytest.mark.filterwarnings("default") +def test_record_attribute_xunit2(testdir): + """Ensure record_xml_attribute drops values when outside of legacy family + """ + testdir.makeini( + """ + [pytest] + junit_family = xunit2 + """ + ) + testdir.makepyfile( + """ + import pytest + + @pytest.fixture + def other(record_xml_attribute): + record_xml_attribute("bar", 1) + def test_record(record_xml_attribute, other): + record_xml_attribute("foo", "<1"); + """ + ) + + result, dom = runandparse(testdir, "-rw") + result.stdout.fnmatch_lines( + [ + "*test_record_attribute_xunit2.py:6:*record_xml_attribute is an experimental feature", + "*test_record_attribute_xunit2.py:6:*record_xml_attribute is incompatible with " + "junit_family: xunit2 (use: legacy|xunit1)", + ] + ) + + def test_random_report_log_xdist(testdir, monkeypatch): """xdist calls pytest_runtest_logreport as they are executed by the slaves, with nodes from several nodes overlapping, so junitxml must cope with that