Fix collection report when collecting a single test item
This commit is contained in:
parent
87e4a28351
commit
46d157fe07
|
@ -282,7 +282,7 @@ class TerminalReporter:
|
||||||
line = "collected "
|
line = "collected "
|
||||||
else:
|
else:
|
||||||
line = "collecting "
|
line = "collecting "
|
||||||
line += str(self._numcollected) + " items"
|
line += str(self._numcollected) + " item" + ('' if self._numcollected == 1 else 's')
|
||||||
if errors:
|
if errors:
|
||||||
line += " / %d errors" % errors
|
line += " / %d errors" % errors
|
||||||
if skipped:
|
if skipped:
|
||||||
|
|
|
@ -513,12 +513,12 @@ def test_pytest_no_tests_collected_exit_status(testdir):
|
||||||
assert 1
|
assert 1
|
||||||
""")
|
""")
|
||||||
result = testdir.runpytest()
|
result = testdir.runpytest()
|
||||||
result.stdout.fnmatch_lines('*collected 1 items*')
|
result.stdout.fnmatch_lines('*collected 1 item*')
|
||||||
result.stdout.fnmatch_lines('*1 passed*')
|
result.stdout.fnmatch_lines('*1 passed*')
|
||||||
assert result.ret == main.EXIT_OK
|
assert result.ret == main.EXIT_OK
|
||||||
|
|
||||||
result = testdir.runpytest('-k nonmatch')
|
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*')
|
result.stdout.fnmatch_lines('*1 deselected*')
|
||||||
assert result.ret == main.EXIT_NOTESTSCOLLECTED
|
assert result.ret == main.EXIT_NOTESTSCOLLECTED
|
||||||
|
|
||||||
|
|
|
@ -204,6 +204,15 @@ class TestTerminal(object):
|
||||||
assert result.ret == 2
|
assert result.ret == 2
|
||||||
result.stdout.fnmatch_lines(['*KeyboardInterrupt*'])
|
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):
|
class TestCollectonly(object):
|
||||||
def test_collectonly_basic(self, testdir):
|
def test_collectonly_basic(self, testdir):
|
||||||
|
|
Loading…
Reference in New Issue