From 9839ceffe0c78c5308716db758532b03e0f908d8 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 11 Dec 2018 20:36:57 -0200 Subject: [PATCH 1/2] Change -ra to show errors and failures last, instead of first Often in large test suites (like pytest's), the -ra summary is very useful to obtain a list of failures so we can execute each test at once to fix them. Problem is the default shows errors and failures first, which leads to a lot of scrolling to get to them. --- src/_pytest/terminal.py | 2 +- testing/test_skipping.py | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/_pytest/terminal.py b/src/_pytest/terminal.py index 6f3893653..1137d52b8 100644 --- a/src/_pytest/terminal.py +++ b/src/_pytest/terminal.py @@ -167,7 +167,7 @@ def getreportopt(config): if char not in reportopts and char != "a": reportopts += char elif char == "a": - reportopts = "fEsxXw" + reportopts = "sxXwEf" return reportopts diff --git a/testing/test_skipping.py b/testing/test_skipping.py index 231c3b6aa..6b18011b6 100644 --- a/testing/test_skipping.py +++ b/testing/test_skipping.py @@ -875,11 +875,22 @@ def test_reportchars_all(testdir): pass def test_4(): pytest.skip("four") + @pytest.fixture + def fail(): + assert 0 + def test_5(fail): + pass """ ) result = testdir.runpytest("-ra") result.stdout.fnmatch_lines( - ["FAIL*test_1*", "SKIP*four*", "XFAIL*test_2*", "XPASS*test_3*"] + [ + "SKIP*four*", + "XFAIL*test_2*", + "XPASS*test_3*", + "ERROR*test_5*", + "FAIL*test_1*", + ] ) From 3cd11617ea8df94989af8e5115c1d235aaea13c2 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 11 Dec 2018 20:40:06 -0200 Subject: [PATCH 2/2] Add CHANGELOG --- changelog/4532.feature.rst | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changelog/4532.feature.rst diff --git a/changelog/4532.feature.rst b/changelog/4532.feature.rst new file mode 100644 index 000000000..ce7eb3729 --- /dev/null +++ b/changelog/4532.feature.rst @@ -0,0 +1,3 @@ +``-ra`` now will show errors and failures last, instead of as the first items in the summary. + +This makes it easier to obtain a list of errors and failures to run tests selectively.