Skip to content

Commit 46d157f

Browse files
committed
Fix collection report when collecting a single test item
1 parent 87e4a28 commit 46d157f

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

_pytest/terminal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ def report_collect(self, final=False):
282282
line = "collected "
283283
else:
284284
line = "collecting "
285-
line += str(self._numcollected) + " items"
285+
line += str(self._numcollected) + " item" + ('' if self._numcollected == 1 else 's')
286286
if errors:
287287
line += " / %d errors" % errors
288288
if skipped:

testing/test_runner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,12 +513,12 @@ def test_foo():
513513
assert 1
514514
""")
515515
result = testdir.runpytest()
516-
result.stdout.fnmatch_lines('*collected 1 items*')
516+
result.stdout.fnmatch_lines('*collected 1 item*')
517517
result.stdout.fnmatch_lines('*1 passed*')
518518
assert result.ret == main.EXIT_OK
519519

520520
result = testdir.runpytest('-k nonmatch')
521-
result.stdout.fnmatch_lines('*collected 1 items*')
521+
result.stdout.fnmatch_lines('*collected 1 item*')
522522
result.stdout.fnmatch_lines('*1 deselected*')
523523
assert result.ret == main.EXIT_NOTESTSCOLLECTED
524524

testing/test_terminal.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,15 @@ def test_foobar():
204204
assert result.ret == 2
205205
result.stdout.fnmatch_lines(['*KeyboardInterrupt*'])
206206

207+
def test_collect_single_item(self, testdir):
208+
"""Use singular 'item' when reporting a single test item"""
209+
testdir.makepyfile("""
210+
def test_foobar():
211+
pass
212+
""")
213+
result = testdir.runpytest()
214+
result.stdout.fnmatch_lines(['collected 1 item'])
215+
207216

208217
class TestCollectonly(object):
209218
def test_collectonly_basic(self, testdir):

0 commit comments

Comments
 (0)