@@ -993,6 +993,20 @@ def test_record_with_same_name(record_property):
993993 pnodes [1 ].assert_attr (name = "foo" , value = "baz" )
994994
995995
996+ @pytest .mark .parametrize ("fixture_name" , ["record_property" , "record_xml_attribute" ])
997+ def test_record_fixtures_without_junitxml (testdir , fixture_name ):
998+ testdir .makepyfile (
999+ """
1000+ def test_record({fixture_name}):
1001+ {fixture_name}("foo", "bar")
1002+ """ .format (
1003+ fixture_name = fixture_name
1004+ )
1005+ )
1006+ result = testdir .runpytest ()
1007+ assert result .ret == 0
1008+
1009+
9961010@pytest .mark .filterwarnings ("default" )
9971011def test_record_attribute (testdir ):
9981012 testdir .makeini (
@@ -1023,8 +1037,9 @@ def test_record(record_xml_attribute, other):
10231037
10241038
10251039@pytest .mark .filterwarnings ("default" )
1026- def test_record_attribute_xunit2 (testdir ):
1027- """Ensure record_xml_attribute drops values when outside of legacy family
1040+ @pytest .mark .parametrize ("fixture_name" , ["record_xml_attribute" , "record_property" ])
1041+ def test_record_fixtures_xunit2 (testdir , fixture_name ):
1042+ """Ensure record_xml_attribute and record_property drop values when outside of legacy family
10281043 """
10291044 testdir .makeini (
10301045 """
@@ -1037,21 +1052,28 @@ def test_record_attribute_xunit2(testdir):
10371052 import pytest
10381053
10391054 @pytest.fixture
1040- def other(record_xml_attribute):
1041- record_xml_attribute("bar", 1)
1042- def test_record(record_xml_attribute, other):
1043- record_xml_attribute("foo", "<1");
1044- """
1055+ def other({fixture_name}):
1056+ {fixture_name}("bar", 1)
1057+ def test_record({fixture_name}, other):
1058+ {fixture_name}("foo", "<1");
1059+ """ .format (
1060+ fixture_name = fixture_name
1061+ )
10451062 )
10461063
10471064 result , dom = runandparse (testdir , "-rw" )
1048- result .stdout .fnmatch_lines (
1049- [
1050- "*test_record_attribute_xunit2.py:6:*record_xml_attribute is an experimental feature" ,
1051- "*test_record_attribute_xunit2.py:6:*record_xml_attribute is incompatible with "
1052- "junit_family: xunit2 (use: legacy|xunit1)" ,
1053- ]
1054- )
1065+ expected_lines = []
1066+ if fixture_name == "record_xml_attribute" :
1067+ expected_lines .append (
1068+ "*test_record_fixtures_xunit2.py:6:*record_xml_attribute is an experimental feature"
1069+ )
1070+ expected_lines = [
1071+ "*test_record_fixtures_xunit2.py:6:*{fixture_name} is incompatible "
1072+ "with junit_family 'xunit2' (use 'legacy' or 'xunit1')" .format (
1073+ fixture_name = fixture_name
1074+ )
1075+ ]
1076+ result .stdout .fnmatch_lines (expected_lines )
10551077
10561078
10571079def test_random_report_log_xdist (testdir , monkeypatch ):
0 commit comments