From a7e49e6c07ff163cdd1e646853d2b52e5d535437 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 7 Apr 2019 17:11:26 +0200 Subject: [PATCH 1/4] reportchars: fix/improve help message --- src/_pytest/terminal.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/_pytest/terminal.py b/src/_pytest/terminal.py index 31c0da46d71..fffdd836a57 100644 --- a/src/_pytest/terminal.py +++ b/src/_pytest/terminal.py @@ -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). " "Warnings are displayed at all times except when " - "--disable-warnings is set", + "--disable-warnings is set.", ) group._addoption( "--disable-warnings", From b4b9f788af45906cec62620db4a9522bf0b3d02f Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 7 Apr 2019 18:03:06 +0200 Subject: [PATCH 2/4] Support reportchars=A (really all, including passed) --- src/_pytest/terminal.py | 11 +++++++---- testing/test_terminal.py | 3 +++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/_pytest/terminal.py b/src/_pytest/terminal.py index fffdd836a57..e8ac6ef6e49 100644 --- a/src/_pytest/terminal.py +++ b/src/_pytest/terminal.py @@ -83,7 +83,7 @@ def pytest_addoption(parser): metavar="chars", 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). " + "(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.", ) @@ -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 + elif char not in reportopts: + reportopts += char return reportopts diff --git a/testing/test_terminal.py b/testing/test_terminal.py index d0fdce23eb6..d730da666e3 100644 --- a/testing/test_terminal.py +++ b/testing/test_terminal.py @@ -838,6 +838,9 @@ class Option(object): config.option.disable_warnings = False assert getreportopt(config) == "sfxw" + config.option.reportchars = "A" + assert getreportopt(config) == "sxXwEfpP" + def test_terminalreporter_reportopt_addopts(testdir): testdir.makeini("[pytest]\naddopts=-rs") From 50edab8004cf425317af64d2fb188d6f4eaf321f Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 7 Apr 2019 18:04:09 +0200 Subject: [PATCH 3/4] Add tests for reportchars=a Ref: https://github.com/pytest-dev/pytest/issues/5066 --- testing/test_terminal.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/testing/test_terminal.py b/testing/test_terminal.py index d730da666e3..2155935d43c 100644 --- a/testing/test_terminal.py +++ b/testing/test_terminal.py @@ -830,14 +830,20 @@ 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" From 42e60d935adb5292e9ae87387a5a61745bd34ab1 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Thu, 11 Apr 2019 11:44:04 +0200 Subject: [PATCH 4/4] doc/changelog --- changelog/5068.feature.rst | 1 + doc/en/usage.rst | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changelog/5068.feature.rst diff --git a/changelog/5068.feature.rst b/changelog/5068.feature.rst new file mode 100644 index 00000000000..bceebffc164 --- /dev/null +++ b/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. diff --git a/doc/en/usage.rst b/doc/en/usage.rst index d6850beda58..1c49f81d6d6 100644 --- a/doc/en/usage.rst +++ b/doc/en/usage.rst @@ -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: @@ -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: