From b81532e4432cba5f5ebbb46f2b9d6b51f394fe25 Mon Sep 17 00:00:00 2001 From: Ben Brown Date: Tue, 2 Jan 2024 11:02:59 -0500 Subject: [PATCH] PR feedback: Improve new unit test --- testing/test_runner.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/testing/test_runner.py b/testing/test_runner.py index d04822a3a..49654a84f 100644 --- a/testing/test_runner.py +++ b/testing/test_runner.py @@ -1090,7 +1090,11 @@ def test_outcome_exception_bad_msg() -> None: def test_teardown_session_failed(pytester: Pytester) -> None: - """Test that fixture teardown failures are reported after a test fails.""" + """Test that higher-scoped fixture teardowns run in the context of the last + item after the test session bails early due to --maxfail. + + Regression test for #11706. + """ pytester.makepyfile( """ import pytest @@ -1108,4 +1112,4 @@ def test_teardown_session_failed(pytester: Pytester) -> None: """ ) result = pytester.runpytest("--maxfail=1") - result.stdout.fnmatch_lines(["*1 failed, 1 error*"]) + result.assert_outcomes(failed=1, errors=1)