diff options
author | Bruno Oliveira <nicoddemus@gmail.com> | 2017-07-27 15:06:35 -0300 |
---|---|---|
committer | Bruno Oliveira <nicoddemus@gmail.com> | 2017-07-28 08:54:55 -0300 |
commit | 75e6f7717c12d9fe50a2b0cd0eed86ea0bc4797d (patch) | |
tree | e7cf8dff582176c6a5237d35e71dcfc6cb297b69 /testing | |
parent | 17121960b45cffa1dea40a1fa14efa4ee5499f9b (diff) | |
download | pytest-75e6f7717c12d9fe50a2b0cd0eed86ea0bc4797d.tar.gz |
Use new hook to report accurate tests skipped in --lf and --ff
Diffstat (limited to 'testing')
-rwxr-xr-x | testing/test_cache.py | 67 |
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=""" |