1 new changeset in pytest:

http://bitbucket.org/hpk42/pytest/changeset/743998323adc/
changeset:   743998323adc
branches:    
user:        hpk42
date:        2011-05-28 14:03:10
summary:     fix issue47 - fix time-per-test timing output for junitxml
affected #:  5 files (525 bytes)

--- a/CHANGELOG Fri May 27 12:58:22 2011 +0200
+++ b/CHANGELOG Sat May 28 14:03:10 2011 +0200
@@ -1,6 +1,7 @@
 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)
 - env/username expansion for junitxml file path (fixes issue44)
 


--- a/_pytest/__init__.py       Fri May 27 12:58:22 2011 +0200
+++ b/_pytest/__init__.py       Sat May 28 14:03:10 2011 +0200
@@ -1,2 +1,2 @@
 #
-__version__ = '2.0.4.dev'
+__version__ = '2.1.0.dev1'


--- a/_pytest/junitxml.py       Fri May 27 12:58:22 2011 +0200
+++ b/_pytest/junitxml.py       Sat May 28 14:03:10 2011 +0200
@@ -76,7 +76,7 @@
         names = report.nodeid.split("::")
         names[0] = names[0].replace("/", '.')
         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 != "()"]
         classnames = names[:-1]
         if self.prefix:
@@ -170,12 +170,11 @@
             self.append_skipped(report)
 
     def pytest_runtest_call(self, item, __multicall__):
-        names = tuple(item.listnames())
         start = time.time()
         try:
             return __multicall__.execute()
         finally:
-            self._durations[names] = time.time() - start
+            self._durations[item.nodeid] = time.time() - start
 
     def pytest_collectreport(self, report):
         if not report.passed:


--- a/setup.py  Fri May 27 12:58:22 2011 +0200
+++ b/setup.py  Sat May 28 14:03:10 2011 +0200
@@ -22,7 +22,7 @@
         name='pytest',
         description='py.test: simple powerful testing with Python',
         long_description = long_description,
-        version='2.0.4.dev',
+        version='2.1.0.dev1',
         url='http://pytest.org',
         license='MIT license',
         platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],


--- a/testing/test_junitxml.py  Fri May 27 12:58:22 2011 +0200
+++ b/testing/test_junitxml.py  Sat May 28 14:03:10 2011 +0200
@@ -39,6 +39,18 @@
         node = dom.getElementsByTagName("testsuite")[0]
         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):
         testdir.makepyfile("""
             def pytest_funcarg__arg(request):

Repository URL: https://bitbucket.org/hpk42/pytest/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
_______________________________________________
py-svn mailing list
py-svn@codespeak.net
http://codespeak.net/mailman/listinfo/py-svn

Reply via email to