Add xfail specific tests

This commit is contained in:
Bruno Oliveira 2017-07-27 10:56:04 -03:00
parent 62810f61b2
commit 22212c4d61
1 changed files with 22 additions and 0 deletions

View File

@ -438,6 +438,28 @@ class TestLastFailed(object):
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", {}))