From 9f86e834782065fea3dae9e31d9a86fe0f5cfb4d Mon Sep 17 00:00:00 2001 From: Kristoffer Nordstroem Date: Fri, 30 Nov 2018 13:19:02 +0100 Subject: [PATCH 1/5] count selected tests --- src/_pytest/terminal.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/_pytest/terminal.py b/src/_pytest/terminal.py index c1d4d1f91..db1316c81 100644 --- a/src/_pytest/terminal.py +++ b/src/_pytest/terminal.py @@ -497,6 +497,7 @@ class TerminalReporter(object): errors = len(self.stats.get("error", [])) skipped = len(self.stats.get("skipped", [])) deselected = len(self.stats.get("deselected", [])) + selected = self._numcollected - errors - skipped - deselected if final: line = "collected " else: @@ -510,6 +511,8 @@ class TerminalReporter(object): line += " / %d deselected" % deselected if skipped: line += " / %d skipped" % skipped + if self._numcollected > selected: + line += " / %d selected" % selected if self.isatty: self.rewrite(line, bold=True, erase=True) if final: From 8723eb16ea377e94d1deacff9e831c46fc9b5c97 Mon Sep 17 00:00:00 2001 From: Kristoffer Nordstroem Date: Thu, 24 Jan 2019 00:00:29 +0100 Subject: [PATCH 2/5] only print selected if any have been selected --- src/_pytest/terminal.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_pytest/terminal.py b/src/_pytest/terminal.py index db1316c81..9a0d7686e 100644 --- a/src/_pytest/terminal.py +++ b/src/_pytest/terminal.py @@ -511,7 +511,7 @@ class TerminalReporter(object): line += " / %d deselected" % deselected if skipped: line += " / %d skipped" % skipped - if self._numcollected > selected: + if self._numcollected > selected > 0: line += " / %d selected" % selected if self.isatty: self.rewrite(line, bold=True, erase=True) From 6d388689500af36bdc10fd7816105433f8f97194 Mon Sep 17 00:00:00 2001 From: Kristoffer Nordstroem Date: Thu, 24 Jan 2019 00:08:43 +0100 Subject: [PATCH 3/5] fix tests by adding additional output to expected responses --- testing/test_cacheprovider.py | 2 +- testing/test_terminal.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/testing/test_cacheprovider.py b/testing/test_cacheprovider.py index 29c2d8a1d..35a7232ab 100644 --- a/testing/test_cacheprovider.py +++ b/testing/test_cacheprovider.py @@ -418,7 +418,7 @@ class TestLastFailed(object): result = testdir.runpytest("--lf") result.stdout.fnmatch_lines( [ - "collected 4 items / 2 deselected", + "collected 4 items / 2 deselected / 2 selected", "run-last-failure: rerun previous 2 failures", "*2 failed, 2 deselected in*", ] diff --git a/testing/test_terminal.py b/testing/test_terminal.py index c0dd21bc2..89d455b39 100644 --- a/testing/test_terminal.py +++ b/testing/test_terminal.py @@ -474,7 +474,7 @@ class TestTerminalFunctional(object): ) result = testdir.runpytest("-k", "test_two:", testpath) result.stdout.fnmatch_lines( - ["collected 3 items / 1 deselected", "*test_deselected.py ..*"] + ["collected 3 items / 1 deselected / 2 selected", "*test_deselected.py ..*"] ) assert result.ret == 0 @@ -498,7 +498,7 @@ class TestTerminalFunctional(object): result = testdir.runpytest("-m", "not foo") result.stdout.fnmatch_lines( [ - "collected 3 items / 1 deselected", + "collected 3 items / 1 deselected / 2 selected", "*test_show_deselected.py ..*", "*= 2 passed, 1 deselected in * =*", ] From 37aab5dd6bccf86deac36198a7e007b97097756d Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Thu, 24 Jan 2019 20:07:21 -0200 Subject: [PATCH 4/5] Add CHANGELOG entry for #4660 --- changelog/4660.feature.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/4660.feature.rst diff --git a/changelog/4660.feature.rst b/changelog/4660.feature.rst new file mode 100644 index 000000000..a8ae5213b --- /dev/null +++ b/changelog/4660.feature.rst @@ -0,0 +1 @@ +The number of *selected* tests now are also displayed when the ``-k`` or ``-m`` flags are used. From e2cd2cd409f34d732418830ef3064569cbf5da4d Mon Sep 17 00:00:00 2001 From: Kristoffer Nordstroem Date: Thu, 24 Jan 2019 23:18:21 +0100 Subject: [PATCH 5/5] vanity commit --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index 06947d17b..20a0fb6bf 100644 --- a/AUTHORS +++ b/AUTHORS @@ -127,6 +127,7 @@ Katerina Koukiou Kevin Cox Kodi B. Arfer Kostis Anagnostopoulos +Kristoffer Nordström Kyle Altendorf Lawrence Mitchell Lee Kamentsky