Fix collection report when collecting a single test item

This commit is contained in:
Bruno Oliveira 2017-06-03 18:42:26 -03:00
parent 87e4a28351
commit 46d157fe07
3 changed files with 12 additions and 3 deletions

View File

@ -282,7 +282,7 @@ class TerminalReporter:
line = "collected "
else:
line = "collecting "
line += str(self._numcollected) + " items"
line += str(self._numcollected) + " item" + ('' if self._numcollected == 1 else 's')
if errors:
line += " / %d errors" % errors
if skipped:

View File

@ -513,12 +513,12 @@ def test_pytest_no_tests_collected_exit_status(testdir):
assert 1
""")
result = testdir.runpytest()
result.stdout.fnmatch_lines('*collected 1 items*')
result.stdout.fnmatch_lines('*collected 1 item*')
result.stdout.fnmatch_lines('*1 passed*')
assert result.ret == main.EXIT_OK
result = testdir.runpytest('-k nonmatch')
result.stdout.fnmatch_lines('*collected 1 items*')
result.stdout.fnmatch_lines('*collected 1 item*')
result.stdout.fnmatch_lines('*1 deselected*')
assert result.ret == main.EXIT_NOTESTSCOLLECTED

View File

@ -204,6 +204,15 @@ class TestTerminal(object):
assert result.ret == 2
result.stdout.fnmatch_lines(['*KeyboardInterrupt*'])
def test_collect_single_item(self, testdir):
"""Use singular 'item' when reporting a single test item"""
testdir.makepyfile("""
def test_foobar():
pass
""")
result = testdir.runpytest()
result.stdout.fnmatch_lines(['collected 1 item'])
class TestCollectonly(object):
def test_collectonly_basic(self, testdir):