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 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. diff --git a/src/_pytest/terminal.py b/src/_pytest/terminal.py index c1d4d1f91..9a0d7686e 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 > 0: + line += " / %d selected" % selected if self.isatty: self.rewrite(line, bold=True, erase=True) if final: 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 * =*", ]