Skip to content

Commit 22212c4

Browse files
committed
Add xfail specific tests
1 parent 62810f6 commit 22212c4

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

testing/test_cache.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,28 @@ def test_lastfailed_creates_cache_when_needed(self, testdir):
438438
testdir.runpytest('-q', '--lf')
439439
assert os.path.exists('.cache')
440440

441+
def test_xfail_not_considered_failure(self, testdir):
442+
testdir.makepyfile('''
443+
import pytest
444+
@pytest.mark.xfail
445+
def test():
446+
assert 0
447+
''')
448+
result = testdir.runpytest()
449+
result.stdout.fnmatch_lines('*1 xfailed*')
450+
assert self.get_cached_last_failed(testdir) == []
451+
452+
def test_xfail_strict_considered_failure(self, testdir):
453+
testdir.makepyfile('''
454+
import pytest
455+
@pytest.mark.xfail(strict=True)
456+
def test():
457+
pass
458+
''')
459+
result = testdir.runpytest()
460+
result.stdout.fnmatch_lines('*1 failed*')
461+
assert self.get_cached_last_failed(testdir) == ['test_xfail_strict_considered_failure.py::test']
462+
441463
def get_cached_last_failed(self, testdir):
442464
config = testdir.parseconfigure()
443465
return sorted(config.cache.get("cache/lastfailed", {}))

0 commit comments

Comments
 (0)