Skip to content

Commit

Permalink
Add xfail specific tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoddemus committed Jul 27, 2017
1 parent 62810f6 commit 22212c4
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions testing/test_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,28 @@ def test_lastfailed_creates_cache_when_needed(self, testdir):
testdir.runpytest('-q', '--lf')
assert os.path.exists('.cache')

def test_xfail_not_considered_failure(self, testdir):
testdir.makepyfile('''
import pytest
@pytest.mark.xfail
def test():
assert 0
''')
result = testdir.runpytest()
result.stdout.fnmatch_lines('*1 xfailed*')
assert self.get_cached_last_failed(testdir) == []

def test_xfail_strict_considered_failure(self, testdir):
testdir.makepyfile('''
import pytest
@pytest.mark.xfail(strict=True)
def test():
pass
''')
result = testdir.runpytest()
result.stdout.fnmatch_lines('*1 failed*')
assert self.get_cached_last_failed(testdir) == ['test_xfail_strict_considered_failure.py::test']

def get_cached_last_failed(self, testdir):
config = testdir.parseconfigure()
return sorted(config.cache.get("cache/lastfailed", {}))
Expand Down

0 comments on commit 22212c4

Please sign in to comment.