diff --git a/changelog/12231.feature.rst b/changelog/12231.feature.rst index 056eebb6b..82b6e5c0a 100644 --- a/changelog/12231.feature.rst +++ b/changelog/12231.feature.rst @@ -1,4 +1,4 @@ -Add `--xfail-tb` flag, which turns traceback output for XFAIL results. +Add `--xfail-tb` flag, which turns traceback output for XFAIL results. * If the `--xfail-tb` flag is not sent, tracebacks for XFAIL results are NOT shown. * The style of traceback for XFAIL is set with `--tb`, and can be `auto|long|short|line|native|no`. @@ -10,4 +10,4 @@ Some history: * With this change, default `-rx`/ `-ra` behavior is identical to pre-8.0 with respect to xfail tracebacks. * With pytest 8.0, `-rx` or `-ra` would not only turn on summary reports for xfail, but also report the tracebacks for xfail results. * This caused issues with some projects that utilize xfail, but don't want to see all of the xfail tracebacks. -* This change detaches xfail tracebacks from `-rx`, and now we turn on xfail tracebacks with `--xfail-tb`. \ No newline at end of file +* This change detaches xfail tracebacks from `-rx`, and now we turn on xfail tracebacks with `--xfail-tb`. diff --git a/testing/test_terminal.py b/testing/test_terminal.py index cb0f8124e..a067bc407 100644 --- a/testing/test_terminal.py +++ b/testing/test_terminal.py @@ -2918,7 +2918,7 @@ def xfail_testfile(pytester: Pytester) -> Path: def test_fail(): a, b = 1, 2 assert a == b - + @pytest.mark.xfail def test_xfail(): c, d = 3, 4 @@ -2926,9 +2926,10 @@ def xfail_testfile(pytester: Pytester) -> Path: """ ) + def test_xfail_tb_default(xfail_testfile, pytester: Pytester) -> None: result = pytester.runpytest(xfail_testfile) - + # test_fail, show traceback result.stdout.fnmatch_lines( [ @@ -2947,7 +2948,7 @@ def test_xfail_tb_default(xfail_testfile, pytester: Pytester) -> None: def test_xfail_tb_true(xfail_testfile, pytester: Pytester) -> None: result = pytester.runpytest(xfail_testfile, "--xfail-tb") - + # both test_fail and test_xfail, show traceback result.stdout.fnmatch_lines( [