summaryrefslogtreecommitdiff
path: root/testing
diff options
context:
space:
mode:
authorBruno Oliveira <nicoddemus@gmail.com>2017-07-28 14:48:23 -0300
committerGitHub <noreply@github.com>2017-07-28 14:48:23 -0300
commit768edde899fe3629a69d55289f82bb0d95635c06 (patch)
tree210328304d8475946b911484a1872bba3cbb2a80 /testing
parent17121960b45cffa1dea40a1fa14efa4ee5499f9b (diff)
parent7a12acb6a1164935ae79030a8220e5be1e999e7d (diff)
downloadpytest-768edde899fe3629a69d55289f82bb0d95635c06.tar.gz
Merge pull request #2624 from nicoddemus/lf-report-after-collection
Fix --last-failed reported items in terminal
Diffstat (limited to 'testing')
-rwxr-xr-xtesting/test_cache.py67
1 files changed, 67 insertions, 0 deletions
diff --git a/testing/test_cache.py b/testing/test_cache.py
index da86a202c..a37170cdd 100755
--- a/testing/test_cache.py
+++ b/testing/test_cache.py
@@ -340,6 +340,73 @@ class TestLastFailed(object):
result = testdir.runpytest()
result.stdout.fnmatch_lines('*1 failed in*')
+ def test_terminal_report_lastfailed(self, testdir):
+ test_a = testdir.makepyfile(test_a="""
+ def test_a1():
+ pass
+ def test_a2():
+ pass
+ """)
+ test_b = testdir.makepyfile(test_b="""
+ def test_b1():
+ assert 0
+ def test_b2():
+ assert 0
+ """)
+ result = testdir.runpytest()
+ result.stdout.fnmatch_lines([
+ 'collected 4 items',
+ '*2 failed, 2 passed in*',
+ ])
+
+ result = testdir.runpytest('--lf')
+ result.stdout.fnmatch_lines([
+ 'collected 4 items',
+ 'run-last-failure: rerun previous 2 failures',
+ '*2 failed, 2 deselected in*',
+ ])
+
+ result = testdir.runpytest(test_a, '--lf')
+ result.stdout.fnmatch_lines([
+ 'collected 2 items',
+ 'run-last-failure: run all (no recorded failures)',
+ '*2 passed in*',
+ ])
+
+ result = testdir.runpytest(test_b, '--lf')
+ result.stdout.fnmatch_lines([
+ 'collected 2 items',
+ 'run-last-failure: rerun previous 2 failures',
+ '*2 failed in*',
+ ])
+
+ result = testdir.runpytest('test_b.py::test_b1', '--lf')
+ result.stdout.fnmatch_lines([
+ 'collected 1 item',
+ 'run-last-failure: rerun previous 1 failure',
+ '*1 failed in*',
+ ])
+
+ def test_terminal_report_failedfirst(self, testdir):
+ testdir.makepyfile(test_a="""
+ def test_a1():
+ assert 0
+ def test_a2():
+ pass
+ """)
+ result = testdir.runpytest()
+ result.stdout.fnmatch_lines([
+ 'collected 2 items',
+ '*1 failed, 1 passed in*',
+ ])
+
+ result = testdir.runpytest('--ff')
+ result.stdout.fnmatch_lines([
+ 'collected 2 items',
+ 'run-last-failure: rerun previous 1 failure first',
+ '*1 failed, 1 passed in*',
+ ])
+
def test_lastfailed_collectfailure(self, testdir, monkeypatch):
testdir.makepyfile(test_maybe="""