2 new commits in pytest:
https://bitbucket.org/pytest-dev/pytest/commits/c662aaf3be4d/
Changeset: c662aaf3be4d
Branch: include-setup-teardown-duration-in-junitxml
User: jpvanhal
Date: 2015-05-01 11:55:52+00:00
Summary: Include setup and teardown in junitxml test durations
Affected #: 2 files
diff -r ce106625d6b53f0ff6e9dce8a1cf0c761341b2f4 -r
c662aaf3be4d5d0ff6701603076641e96b7b70dc _pytest/junitxml.py
--- a/_pytest/junitxml.py
+++ b/_pytest/junitxml.py
@@ -96,7 +96,7 @@
self.tests.append(Junit.testcase(
classname=".".join(classnames),
name=bin_xml_escape(names[-1]),
- time=getattr(report, 'duration', 0)
+ time=0
))
def _write_captured_output(self, report):
@@ -168,18 +168,18 @@
self._write_captured_output(report)
def pytest_runtest_logreport(self, report):
+ if report.when == "setup":
+ self._opentestcase(report)
+ self.tests[-1].attr.time += getattr(report, 'duration', 0)
if report.passed:
if report.when == "call": # ignore setup/teardown
- self._opentestcase(report)
self.append_pass(report)
elif report.failed:
- self._opentestcase(report)
if report.when != "call":
self.append_error(report)
else:
self.append_failure(report)
elif report.skipped:
- self._opentestcase(report)
self.append_skipped(report)
def pytest_collectreport(self, report):
diff -r ce106625d6b53f0ff6e9dce8a1cf0c761341b2f4 -r
c662aaf3be4d5d0ff6701603076641e96b7b70dc testing/test_junitxml.py
--- a/testing/test_junitxml.py
+++ b/testing/test_junitxml.py
@@ -44,6 +44,10 @@
def test_timing_function(self, testdir):
testdir.makepyfile("""
import time, pytest
+ def setup_module():
+ time.sleep(0.01)
+ def teardown_module():
+ time.sleep(0.01)
def test_sleep():
time.sleep(0.01)
""")
@@ -51,7 +55,7 @@
node = dom.getElementsByTagName("testsuite")[0]
tnode = node.getElementsByTagName("testcase")[0]
val = tnode.getAttributeNode("time").value
- assert float(val) >= 0.001
+ assert float(val) >= 0.03
def test_setup_error(self, testdir):
testdir.makepyfile("""
https://bitbucket.org/pytest-dev/pytest/commits/7bad072348c4/
Changeset: 7bad072348c4
User: RonnyPfannschmidt
Date: 2015-06-06 09:50:37+00:00
Summary: Merged in
jpvanhal/pytest/include-setup-teardown-duration-in-junitxml (pull request #287)
Include setup and teardown in junitxml test durations
Affected #: 2 files
diff -r 61d638f89acbda40a49ccadcb4aebe06783200df -r
7bad072348c45897c52d31eb2765a97e11721eba _pytest/junitxml.py
--- a/_pytest/junitxml.py
+++ b/_pytest/junitxml.py
@@ -96,7 +96,7 @@
self.tests.append(Junit.testcase(
classname=".".join(classnames),
name=bin_xml_escape(names[-1]),
- time=getattr(report, 'duration', 0)
+ time=0
))
def _write_captured_output(self, report):
@@ -168,18 +168,18 @@
self._write_captured_output(report)
def pytest_runtest_logreport(self, report):
+ if report.when == "setup":
+ self._opentestcase(report)
+ self.tests[-1].attr.time += getattr(report, 'duration', 0)
if report.passed:
if report.when == "call": # ignore setup/teardown
- self._opentestcase(report)
self.append_pass(report)
elif report.failed:
- self._opentestcase(report)
if report.when != "call":
self.append_error(report)
else:
self.append_failure(report)
elif report.skipped:
- self._opentestcase(report)
self.append_skipped(report)
def pytest_collectreport(self, report):
diff -r 61d638f89acbda40a49ccadcb4aebe06783200df -r
7bad072348c45897c52d31eb2765a97e11721eba testing/test_junitxml.py
--- a/testing/test_junitxml.py
+++ b/testing/test_junitxml.py
@@ -44,6 +44,10 @@
def test_timing_function(self, testdir):
testdir.makepyfile("""
import time, pytest
+ def setup_module():
+ time.sleep(0.01)
+ def teardown_module():
+ time.sleep(0.01)
def test_sleep():
time.sleep(0.01)
""")
@@ -51,7 +55,7 @@
node = dom.getElementsByTagName("testsuite")[0]
tnode = node.getElementsByTagName("testcase")[0]
val = tnode.getAttributeNode("time").value
- assert float(val) >= 0.001
+ assert float(val) >= 0.03
def test_setup_error(self, testdir):
testdir.makepyfile("""
Repository URL: https://bitbucket.org/pytest-dev/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.
_______________________________________________
pytest-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pytest-commit