Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for reportchars=A (-rA) #5068

Merged
merged 4 commits into from Apr 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/5068.feature.rst
@@ -0,0 +1 @@
The ``-r`` option learnt about ``A`` to display all reports (including passed ones) in the short test summary.
nicoddemus marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 3 additions & 1 deletion doc/en/usage.rst
Expand Up @@ -235,7 +235,8 @@ Example:
FAILED test_example.py::test_fail
= 1 failed, 1 passed, 1 skipped, 1 xfailed, 1 xpassed, 1 error in 0.12 seconds =

The ``-r`` options accepts a number of characters after it, with ``a`` used above meaning "all except passes".
The ``-r`` options accepts a number of characters after it, with ``a`` used
above meaning "all except passes".

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

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

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

Expand Down
17 changes: 10 additions & 7 deletions src/_pytest/terminal.py
Expand Up @@ -81,11 +81,11 @@ def pytest_addoption(parser):
dest="reportchars",
default="",
metavar="chars",
help="show extra test summary info as specified by chars (f)ailed, "
"(E)error, (s)skipped, (x)failed, (X)passed, "
"(p)passed, (P)passed with output, (a)all except pP. "
help="show extra test summary info as specified by chars: (f)ailed, "
"(E)rror, (s)kipped, (x)failed, (X)passed, "
"(p)assed, (P)assed with output, (a)ll except passed (p/P), or (A)ll. "
"Warnings are displayed at all times except when "
"--disable-warnings is set",
"--disable-warnings is set.",
)
group._addoption(
"--disable-warnings",
Expand Down Expand Up @@ -166,10 +166,13 @@ def getreportopt(config):
reportchars = reportchars.replace("w", "")
if reportchars:
for char in reportchars:
if char not in reportopts and char != "a":
reportopts += char
elif char == "a":
if char == "a":
reportopts = "sxXwEf"
elif char == "A":
reportopts = "sxXwEfpP"
break
nicoddemus marked this conversation as resolved.
Show resolved Hide resolved
elif char not in reportopts:
reportopts += char
return reportopts


Expand Down
13 changes: 11 additions & 2 deletions testing/test_terminal.py
Expand Up @@ -830,14 +830,23 @@ class Option(object):
config.option.reportchars = "sfxw"
assert getreportopt(config) == "sfx"

config.option.reportchars = "sfx"
# Now with --disable-warnings.
config.option.disable_warnings = False
config.option.reportchars = "a"
assert getreportopt(config) == "sxXwEf" # NOTE: "w" included!

config.option.reportchars = "sfx"
assert getreportopt(config) == "sfxw"

config.option.reportchars = "sfxw"
config.option.disable_warnings = False
assert getreportopt(config) == "sfxw"

config.option.reportchars = "a"
assert getreportopt(config) == "sxXwEf" # NOTE: "w" included!

config.option.reportchars = "A"
assert getreportopt(config) == "sxXwEfpP"


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