55import sys
66from typing import Literal
77
8+ from _pytest ._io .saferepr import saferepr
89from _pytest .subtests import SubtestContext
910from _pytest .subtests import SubtestReport
1011import pytest
@@ -304,10 +305,10 @@ def test_foo(subtests, x):
304305 result = pytester .runpytest ("-v" )
305306 result .stdout .fnmatch_lines (
306307 [
307- "*.py::test_foo[[]0[]] SUBFAILED[[]custom[]] (i=1 ) *[[] 50%[]]" ,
308- "*.py::test_foo[[]0[]] FAILED *[[] 50%[]]" ,
309- "*.py::test_foo[[]1[]] SUBFAILED[[]custom[]] (i=1 ) *[[]100%[]]" ,
310- "*.py::test_foo[[]1[]] FAILED *[[]100%[]]" ,
308+ "*.py::test_foo[[]0[]] SUBFAILED[[]custom[]] (i='1' ) *[[] 50%[]]" ,
309+ "*.py::test_foo[[]0[]] FAILED *[[] 50%[]]" ,
310+ "*.py::test_foo[[]1[]] SUBFAILED[[]custom[]] (i='1' ) *[[]100%[]]" ,
311+ "*.py::test_foo[[]1[]] FAILED *[[]100%[]]" ,
311312 "contains 1 failed subtest" ,
312313 "* 4 failed, 4 subtests passed in *" ,
313314 ]
@@ -322,10 +323,10 @@ def test_foo(subtests, x):
322323 result = pytester .runpytest ("-v" )
323324 result .stdout .fnmatch_lines (
324325 [
325- "*.py::test_foo[[]0[]] SUBFAILED[[]custom[]] (i=1 ) *[[] 50%[]]" ,
326- "*.py::test_foo[[]0[]] FAILED *[[] 50%[]]" ,
327- "*.py::test_foo[[]1[]] SUBFAILED[[]custom[]] (i=1 ) *[[]100%[]]" ,
328- "*.py::test_foo[[]1[]] FAILED *[[]100%[]]" ,
326+ "*.py::test_foo[[]0[]] SUBFAILED[[]custom[]] (i='1' ) *[[] 50%[]]" ,
327+ "*.py::test_foo[[]0[]] FAILED *[[] 50%[]]" ,
328+ "*.py::test_foo[[]1[]] SUBFAILED[[]custom[]] (i='1' ) *[[]100%[]]" ,
329+ "*.py::test_foo[[]1[]] FAILED *[[]100%[]]" ,
329330 "contains 1 failed subtest" ,
330331 "* 4 failed in *" ,
331332 ]
@@ -652,12 +653,12 @@ def test_capturing(self, pytester: pytest.Pytester, mode: str) -> None:
652653 result = pytester .runpytest (f"--capture={ mode } " )
653654 result .stdout .fnmatch_lines (
654655 [
655- "*__ test (i='A') __*" ,
656+ "*__ test (i=\" 'A'\" ) __*" ,
656657 "*Captured stdout call*" ,
657658 "hello stdout A" ,
658659 "*Captured stderr call*" ,
659660 "hello stderr A" ,
660- "*__ test (i='B') __*" ,
661+ "*__ test (i=\" 'B'\" ) __*" ,
661662 "*Captured stdout call*" ,
662663 "hello stdout B" ,
663664 "*Captured stderr call*" ,
@@ -678,8 +679,8 @@ def test_no_capture(self, pytester: pytest.Pytester) -> None:
678679 "hello stdout A" ,
679680 "uhello stdout B" ,
680681 "uend test" ,
681- "*__ test (i='A') __*" ,
682- "*__ test (i='B') __*" ,
682+ "*__ test (i=\" 'A'\" ) __*" ,
683+ "*__ test (i=\" 'B'\" ) __*" ,
683684 "*__ test __*" ,
684685 ]
685686 )
@@ -986,7 +987,7 @@ def test_serialization() -> None:
986987 new_report = pytest_report_from_serializable (data )
987988 assert new_report is not None
988989 assert new_report .context == SubtestContext (
989- msg = "custom message" , kwargs = dict (i = 10 , a = MyEnum .A )
990+ msg = "custom message" , kwargs = dict (i = saferepr ( 10 ) , a = saferepr ( MyEnum .A ) )
990991 )
991992
992993
0 commit comments