xfail and skipped tests are removed from the "last-failed" cache

This accommodates the case where a failing test is marked as
skipped/failed later
This commit is contained in:
Bruno Oliveira
2017-07-27 18:43:04 -03:00
parent 22212c4d61
commit eb1bd3449e
2 changed files with 23 additions and 1 deletions

View File

@@ -460,6 +460,28 @@ class TestLastFailed(object):
result.stdout.fnmatch_lines('*1 failed*')
assert self.get_cached_last_failed(testdir) == ['test_xfail_strict_considered_failure.py::test']
@pytest.mark.parametrize('mark', ['mark.xfail', 'mark.skip'])
def test_failed_changed_to_xfail_or_skip(self, testdir, mark):
testdir.makepyfile('''
import pytest
def test():
assert 0
''')
result = testdir.runpytest()
assert self.get_cached_last_failed(testdir) == ['test_failed_changed_to_xfail_or_skip.py::test']
assert result.ret == 1
testdir.makepyfile('''
import pytest
@pytest.{mark}
def test():
assert 0
'''.format(mark=mark))
result = testdir.runpytest()
assert result.ret == 0
assert self.get_cached_last_failed(testdir) == []
assert result.ret == 0
def get_cached_last_failed(self, testdir):
config = testdir.parseconfigure()
return sorted(config.cache.get("cache/lastfailed", {}))