fix issue47 - fix time-per-test timing output for junitxml
This commit is contained in:
parent
70d22fbe9a
commit
8dc4e732f0
|
@ -1,6 +1,7 @@
|
||||||
Changes between 2.0.3 and DEV
|
Changes between 2.0.3 and DEV
|
||||||
----------------------------------------------
|
----------------------------------------------
|
||||||
|
|
||||||
|
- fix issue47: timing output in junitxml for test cases is now correct
|
||||||
- introduce XXX pytest_configure_funcargs hack (thanks Ronny)
|
- introduce XXX pytest_configure_funcargs hack (thanks Ronny)
|
||||||
- env/username expansion for junitxml file path (fixes issue44)
|
- env/username expansion for junitxml file path (fixes issue44)
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
#
|
#
|
||||||
__version__ = '2.0.4.dev'
|
__version__ = '2.1.0.dev1'
|
||||||
|
|
|
@ -76,7 +76,7 @@ class LogXML(object):
|
||||||
names = report.nodeid.split("::")
|
names = report.nodeid.split("::")
|
||||||
names[0] = names[0].replace("/", '.')
|
names[0] = names[0].replace("/", '.')
|
||||||
names = tuple(names)
|
names = tuple(names)
|
||||||
d = {'time': self._durations.pop(names, "0")}
|
d = {'time': self._durations.pop(report.nodeid, "0")}
|
||||||
names = [x.replace(".py", "") for x in names if x != "()"]
|
names = [x.replace(".py", "") for x in names if x != "()"]
|
||||||
classnames = names[:-1]
|
classnames = names[:-1]
|
||||||
if self.prefix:
|
if self.prefix:
|
||||||
|
@ -170,12 +170,11 @@ class LogXML(object):
|
||||||
self.append_skipped(report)
|
self.append_skipped(report)
|
||||||
|
|
||||||
def pytest_runtest_call(self, item, __multicall__):
|
def pytest_runtest_call(self, item, __multicall__):
|
||||||
names = tuple(item.listnames())
|
|
||||||
start = time.time()
|
start = time.time()
|
||||||
try:
|
try:
|
||||||
return __multicall__.execute()
|
return __multicall__.execute()
|
||||||
finally:
|
finally:
|
||||||
self._durations[names] = time.time() - start
|
self._durations[item.nodeid] = time.time() - start
|
||||||
|
|
||||||
def pytest_collectreport(self, report):
|
def pytest_collectreport(self, report):
|
||||||
if not report.passed:
|
if not report.passed:
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -22,7 +22,7 @@ def main():
|
||||||
name='pytest',
|
name='pytest',
|
||||||
description='py.test: simple powerful testing with Python',
|
description='py.test: simple powerful testing with Python',
|
||||||
long_description = long_description,
|
long_description = long_description,
|
||||||
version='2.0.4.dev',
|
version='2.1.0.dev1',
|
||||||
url='http://pytest.org',
|
url='http://pytest.org',
|
||||||
license='MIT license',
|
license='MIT license',
|
||||||
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],
|
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],
|
||||||
|
|
|
@ -39,6 +39,18 @@ class TestPython:
|
||||||
node = dom.getElementsByTagName("testsuite")[0]
|
node = dom.getElementsByTagName("testsuite")[0]
|
||||||
assert_attr(node, errors=0, failures=1, skips=3, tests=2)
|
assert_attr(node, errors=0, failures=1, skips=3, tests=2)
|
||||||
|
|
||||||
|
def test_timing_function(self, testdir):
|
||||||
|
testdir.makepyfile("""
|
||||||
|
import time, pytest
|
||||||
|
def test_sleep():
|
||||||
|
time.sleep(0.01)
|
||||||
|
""")
|
||||||
|
result, dom = runandparse(testdir)
|
||||||
|
node = dom.getElementsByTagName("testsuite")[0]
|
||||||
|
tnode = node.getElementsByTagName("testcase")[0]
|
||||||
|
val = tnode.getAttributeNode("time").value
|
||||||
|
assert float(val) >= 0.01
|
||||||
|
|
||||||
def test_setup_error(self, testdir):
|
def test_setup_error(self, testdir):
|
||||||
testdir.makepyfile("""
|
testdir.makepyfile("""
|
||||||
def pytest_funcarg__arg(request):
|
def pytest_funcarg__arg(request):
|
||||||
|
|
Loading…
Reference in New Issue