@@ -859,16 +859,21 @@ def test_doctest_id(self, testdir):
859859 4
860860 """ ,
861861 )
862- result = testdir .runpytest ("-rf" )
863- lines = result .stdout .str ().splitlines ()
864- for line in lines :
865- if line .startswith (("FAIL " , "FAILED " )):
866- _fail , _sep , testid = line .partition (" " )
867- break
868- result = testdir .runpytest (testid , "-rf" )
869- result .stdout .fnmatch_lines (
870- ["FAILED test_doctest_id.txt::test_doctest_id.txt" , "*1 failed*" ]
871- )
862+ testid = "test_doctest_id.txt::test_doctest_id.txt"
863+ expected_lines = [
864+ "*= FAILURES =*" ,
865+ "*_ ?doctest? test_doctest_id.txt _*" ,
866+ "FAILED test_doctest_id.txt::test_doctest_id.txt" ,
867+ "*= 1 failed in*" ,
868+ ]
869+ result = testdir .runpytest (testid , "-rf" , "--tb=short" )
870+ result .stdout .fnmatch_lines (expected_lines )
871+
872+ # Ensure that re-running it will still handle it as
873+ # doctest.DocTestFailure, which was not the case before when
874+ # re-importing doctest, but not creating a new RUNNER_CLASS.
875+ result = testdir .runpytest (testid , "-rf" , "--tb=short" )
876+ result .stdout .fnmatch_lines (expected_lines )
872877
873878 def test_core_backward_compatibility (self ):
874879 """Test backward compatibility for get_plugin_manager function. See #787."""
0 commit comments