Merge pull request #4673 from kown7/count-tests

Count tests
This commit is contained in:
Bruno Oliveira 2019-01-24 20:46:29 -02:00 committed by GitHub
commit 51dd738b1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 3 deletions

View File

@ -127,6 +127,7 @@ Katerina Koukiou
Kevin Cox Kevin Cox
Kodi B. Arfer Kodi B. Arfer
Kostis Anagnostopoulos Kostis Anagnostopoulos
Kristoffer Nordström
Kyle Altendorf Kyle Altendorf
Lawrence Mitchell Lawrence Mitchell
Lee Kamentsky Lee Kamentsky

View File

@ -0,0 +1 @@
The number of *selected* tests now are also displayed when the ``-k`` or ``-m`` flags are used.

View File

@ -497,6 +497,7 @@ class TerminalReporter(object):
errors = len(self.stats.get("error", [])) errors = len(self.stats.get("error", []))
skipped = len(self.stats.get("skipped", [])) skipped = len(self.stats.get("skipped", []))
deselected = len(self.stats.get("deselected", [])) deselected = len(self.stats.get("deselected", []))
selected = self._numcollected - errors - skipped - deselected
if final: if final:
line = "collected " line = "collected "
else: else:
@ -510,6 +511,8 @@ class TerminalReporter(object):
line += " / %d deselected" % deselected line += " / %d deselected" % deselected
if skipped: if skipped:
line += " / %d skipped" % skipped line += " / %d skipped" % skipped
if self._numcollected > selected > 0:
line += " / %d selected" % selected
if self.isatty: if self.isatty:
self.rewrite(line, bold=True, erase=True) self.rewrite(line, bold=True, erase=True)
if final: if final:

View File

@ -418,7 +418,7 @@ class TestLastFailed(object):
result = testdir.runpytest("--lf") result = testdir.runpytest("--lf")
result.stdout.fnmatch_lines( result.stdout.fnmatch_lines(
[ [
"collected 4 items / 2 deselected", "collected 4 items / 2 deselected / 2 selected",
"run-last-failure: rerun previous 2 failures", "run-last-failure: rerun previous 2 failures",
"*2 failed, 2 deselected in*", "*2 failed, 2 deselected in*",
] ]

View File

@ -474,7 +474,7 @@ class TestTerminalFunctional(object):
) )
result = testdir.runpytest("-k", "test_two:", testpath) result = testdir.runpytest("-k", "test_two:", testpath)
result.stdout.fnmatch_lines( 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 assert result.ret == 0
@ -498,7 +498,7 @@ class TestTerminalFunctional(object):
result = testdir.runpytest("-m", "not foo") result = testdir.runpytest("-m", "not foo")
result.stdout.fnmatch_lines( result.stdout.fnmatch_lines(
[ [
"collected 3 items / 1 deselected", "collected 3 items / 1 deselected / 2 selected",
"*test_show_deselected.py ..*", "*test_show_deselected.py ..*",
"*= 2 passed, 1 deselected in * =*", "*= 2 passed, 1 deselected in * =*",
] ]