Skip to content

Commit 19035f4

Browse files
authored
Merge pull request #5068 from blueyed/reportchars
Add support for reportchars=A (`-rA`)
2 parents 48ed437 + 42e60d9 commit 19035f4

File tree

4 files changed

+25
-10
lines changed

4 files changed

+25
-10
lines changed

changelog/5068.feature.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The ``-r`` option learnt about ``A`` to display all reports (including passed ones) in the short test summary.

doc/en/usage.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,8 @@ Example:
235235
FAILED test_example.py::test_fail
236236
= 1 failed, 1 passed, 1 skipped, 1 xfailed, 1 xpassed, 1 error in 0.12 seconds =
237237
238-
The ``-r`` options accepts a number of characters after it, with ``a`` used above meaning "all except passes".
238+
The ``-r`` options accepts a number of characters after it, with ``a`` used
239+
above meaning "all except passes".
239240

240241
Here is the full list of available characters that can be used:
241242

@@ -247,6 +248,7 @@ Here is the full list of available characters that can be used:
247248
- ``p`` - passed
248249
- ``P`` - passed with output
249250
- ``a`` - all except ``pP``
251+
- ``A`` - all
250252

251253
More than one character can be used, so for example to only see failed and skipped tests, you can execute:
252254

src/_pytest/terminal.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ def pytest_addoption(parser):
8282
dest="reportchars",
8383
default="",
8484
metavar="chars",
85-
help="show extra test summary info as specified by chars (f)ailed, "
86-
"(E)error, (s)skipped, (x)failed, (X)passed, "
87-
"(p)passed, (P)passed with output, (a)all except pP. "
85+
help="show extra test summary info as specified by chars: (f)ailed, "
86+
"(E)rror, (s)kipped, (x)failed, (X)passed, "
87+
"(p)assed, (P)assed with output, (a)ll except passed (p/P), or (A)ll. "
8888
"Warnings are displayed at all times except when "
89-
"--disable-warnings is set",
89+
"--disable-warnings is set.",
9090
)
9191
group._addoption(
9292
"--disable-warnings",
@@ -167,10 +167,13 @@ def getreportopt(config):
167167
reportchars = reportchars.replace("w", "")
168168
if reportchars:
169169
for char in reportchars:
170-
if char not in reportopts and char != "a":
171-
reportopts += char
172-
elif char == "a":
170+
if char == "a":
173171
reportopts = "sxXwEf"
172+
elif char == "A":
173+
reportopts = "sxXwEfpP"
174+
break
175+
elif char not in reportopts:
176+
reportopts += char
174177
return reportopts
175178

176179

testing/test_terminal.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -831,14 +831,23 @@ class Option(object):
831831
config.option.reportchars = "sfxw"
832832
assert getreportopt(config) == "sfx"
833833

834-
config.option.reportchars = "sfx"
834+
# Now with --disable-warnings.
835835
config.option.disable_warnings = False
836+
config.option.reportchars = "a"
837+
assert getreportopt(config) == "sxXwEf" # NOTE: "w" included!
838+
839+
config.option.reportchars = "sfx"
836840
assert getreportopt(config) == "sfxw"
837841

838842
config.option.reportchars = "sfxw"
839-
config.option.disable_warnings = False
840843
assert getreportopt(config) == "sfxw"
841844

845+
config.option.reportchars = "a"
846+
assert getreportopt(config) == "sxXwEf" # NOTE: "w" included!
847+
848+
config.option.reportchars = "A"
849+
assert getreportopt(config) == "sxXwEfpP"
850+
842851

843852
def test_terminalreporter_reportopt_addopts(testdir):
844853
testdir.makeini("[pytest]\naddopts=-rs")

0 commit comments

Comments
 (0)