fix duration option in case of collection errors

This commit is contained in:
holger krekel 2011-11-08 19:00:25 +00:00
parent ae53d04780
commit 0b18b6094e
4 changed files with 15 additions and 6 deletions

View File

@ -1,2 +1,2 @@
#
__version__ = '2.2.0.dev3'
__version__ = '2.2.0.dev4'

View File

@ -28,9 +28,8 @@ def pytest_terminal_summary(terminalreporter):
duration2rep = {}
alldurations = 0.0
for key, replist in tr.stats.items():
if key == "deselected":
continue
for rep in replist:
if hasattr(rep, 'duration'):
duration2rep[rep.duration] = rep
alldurations += rep.duration
if not duration2rep:

View File

@ -24,7 +24,7 @@ def main():
name='pytest',
description='py.test: simple powerful testing with Python',
long_description = long_description,
version='2.2.0.dev3',
version='2.2.0.dev4',
url='http://pytest.org',
license='MIT license',
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],

View File

@ -523,6 +523,16 @@ class TestDurations:
"*call*test_1*",
])
def test_with_failing_collection(self, testdir):
testdir.makepyfile(self.source)
testdir.makepyfile(test_collecterror="""xyz""")
result = testdir.runpytest("--durations=2", "-k test_1")
assert result.ret != 0
result.stdout.fnmatch_lines([
"*durations*",
"*call*test_1*",
])
class TestDurationWithFixture:
source = """