File tree 2 files changed +23
-1
lines changed 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -117,7 +117,7 @@ def pytest_report_header(self):
117
117
return "run-last-failure: %s" % mode
118
118
119
119
def pytest_runtest_logreport (self , report ):
120
- if report .passed and report . when == 'call' :
120
+ if ( report .when == 'call' and report . passed ) or report . skipped :
121
121
self .lastfailed .pop (report .nodeid , None )
122
122
elif report .failed :
123
123
self .lastfailed [report .nodeid ] = True
Original file line number Diff line number Diff line change @@ -460,6 +460,28 @@ def test():
460
460
result .stdout .fnmatch_lines ('*1 failed*' )
461
461
assert self .get_cached_last_failed (testdir ) == ['test_xfail_strict_considered_failure.py::test' ]
462
462
463
+ @pytest .mark .parametrize ('mark' , ['mark.xfail' , 'mark.skip' ])
464
+ def test_failed_changed_to_xfail_or_skip (self , testdir , mark ):
465
+ testdir .makepyfile ('''
466
+ import pytest
467
+ def test():
468
+ assert 0
469
+ ''' )
470
+ result = testdir .runpytest ()
471
+ assert self .get_cached_last_failed (testdir ) == ['test_failed_changed_to_xfail_or_skip.py::test' ]
472
+ assert result .ret == 1
473
+
474
+ testdir .makepyfile ('''
475
+ import pytest
476
+ @pytest.{mark}
477
+ def test():
478
+ assert 0
479
+ ''' .format (mark = mark ))
480
+ result = testdir .runpytest ()
481
+ assert result .ret == 0
482
+ assert self .get_cached_last_failed (testdir ) == []
483
+ assert result .ret == 0
484
+
463
485
def get_cached_last_failed (self , testdir ):
464
486
config = testdir .parseconfigure ()
465
487
return sorted (config .cache .get ("cache/lastfailed" , {}))
You can’t perform that action at this time.
0 commit comments