@@ -1378,12 +1378,46 @@ def test_record(record_xml_attribute, other):
13781378 )
13791379
13801380
1381+ @pytest .mark .filterwarnings ("default" )
1382+ def test_record_property_xunit2 (pytester : Pytester , run_and_parse : RunAndParse ) -> None :
1383+ pytester .makeini (
1384+ """
1385+ [pytest]
1386+ junit_family = xunit2
1387+ """
1388+ )
1389+ pytester .makepyfile (
1390+ """
1391+ import pytest
1392+
1393+ @pytest.fixture
1394+ def other(record_property):
1395+ record_property("bar", 1)
1396+
1397+ def test_record(record_property, other):
1398+ record_property("foo", "<1")
1399+ """
1400+ )
1401+
1402+ result , dom = run_and_parse (family = None )
1403+ node = dom .get_first_by_tag ("testsuite" )
1404+ tnode = node .get_first_by_tag ("testcase" )
1405+ psnode = tnode .get_first_by_tag ("properties" )
1406+ pnodes = psnode .find_by_tag ("property" )
1407+ pnodes [0 ].assert_attr (name = "bar" , value = "1" )
1408+ pnodes [1 ].assert_attr (name = "foo" , value = "<1" )
1409+
1410+ result .stdout .no_fnmatch_line (
1411+ "*record_property is incompatible with junit_family 'xunit2'*"
1412+ )
1413+
1414+
13811415@pytest .mark .filterwarnings ("default" )
13821416@pytest .mark .parametrize ("fixture_name" , ["record_xml_attribute" , "record_property" ])
13831417def test_record_fixtures_xunit2 (
13841418 pytester : Pytester , fixture_name : str , run_and_parse : RunAndParse
13851419) -> None :
1386- """Ensure record_xml_attribute and record_property drop values when outside of legacy family ."""
1420+ """Ensure xunit2 still warns for record_xml_attribute, but record_property remains supported ."""
13871421 pytester .makeini (
13881422 """
13891423 [pytest]
@@ -1403,16 +1437,16 @@ def test_record({fixture_name}, other):
14031437 )
14041438
14051439 result , _dom = run_and_parse (family = None )
1406- expected_lines = []
14071440 if fixture_name == "record_xml_attribute" :
1408- expected_lines .append (
1409- "*test_record_fixtures_xunit2.py:6:*record_xml_attribute is an experimental feature"
1441+ expected_lines = [
1442+ "*test_record_fixtures_xunit2.py:6:*record_xml_attribute is incompatible "
1443+ "with junit_family 'xunit2' (use 'legacy' or 'xunit1')"
1444+ ]
1445+ result .stdout .fnmatch_lines (expected_lines )
1446+ else :
1447+ result .stdout .no_fnmatch_line (
1448+ "*record_property is incompatible with junit_family 'xunit2'*"
14101449 )
1411- expected_lines = [
1412- f"*test_record_fixtures_xunit2.py:6:*{ fixture_name } is incompatible "
1413- "with junit_family 'xunit2' (use 'legacy' or 'xunit1')"
1414- ]
1415- result .stdout .fnmatch_lines (expected_lines )
14161450
14171451
14181452def test_random_report_log_xdist (
0 commit comments