@@ -993,6 +993,20 @@ def test_record_with_same_name(record_property):
993
993
pnodes [1 ].assert_attr (name = "foo" , value = "baz" )
994
994
995
995
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
+
996
1010
@pytest .mark .filterwarnings ("default" )
997
1011
def test_record_attribute (testdir ):
998
1012
testdir .makeini (
@@ -1023,8 +1037,9 @@ def test_record(record_xml_attribute, other):
1023
1037
1024
1038
1025
1039
@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
1028
1043
"""
1029
1044
testdir .makeini (
1030
1045
"""
@@ -1037,21 +1052,28 @@ def test_record_attribute_xunit2(testdir):
1037
1052
import pytest
1038
1053
1039
1054
@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
+ )
1045
1062
)
1046
1063
1047
1064
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 )
1055
1077
1056
1078
1057
1079
def test_random_report_log_xdist (testdir , monkeypatch ):
0 commit comments