From d6ce5475088968af87c936988ef038fdcf083281 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Thu, 27 Jul 2017 10:56:04 -0300 Subject: [PATCH] Add xfail specific tests --- testing/test_cache.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/testing/test_cache.py b/testing/test_cache.py index 04ce6671cd4..1b2c1499ea6 100755 --- a/testing/test_cache.py +++ b/testing/test_cache.py @@ -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", {}))