From 3a9788fc6f19c53e665e7bdcb4c43907d0320a27 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Sat, 19 Mar 2011 17:59:07 +0100 Subject: [PATCH] fix missing reason/name information for skipped tests --- CHANGELOG | 3 +++ _pytest/junitxml.py | 8 +++++++- pytest.py | 2 +- setup.py | 2 +- testing/test_junitxml.py | 20 ++++++++++++++++++++ 5 files changed, 32 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index b80c5a66a..23869e22f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,9 @@ Changes between 2.0.2 and 2.0.3.dev ---------------------------------------------- +- fix missing skip reason/meta information in junitxml files, reported + via http://lists.idyll.org/pipermail/testing-in-python/2011-March/003928.html + - fix issue34: avoid collection failure with "test" prefixed classes deriving from object. diff --git a/_pytest/junitxml.py b/_pytest/junitxml.py index db6c5a8b2..d28b19efb 100644 --- a/_pytest/junitxml.py +++ b/_pytest/junitxml.py @@ -106,7 +106,13 @@ class LogXML(object): '%s', report.keywords['xfail']) else: - self.appendlog("") + filename, lineno, skipreason = report.longrepr + if skipreason.startswith("Skipped: "): + skipreason = skipreason[9:] + self.appendlog('%s', + skipreason, "%s:%s: %s" % report.longrepr, + ) self._closetestcase() self.skipped += 1 diff --git a/pytest.py b/pytest.py index 90757b93c..baa3bb4e2 100644 --- a/pytest.py +++ b/pytest.py @@ -1,7 +1,7 @@ """ unit and functional testing with Python. """ -__version__ = '2.0.3.dev2' +__version__ = '2.0.3.dev3' __all__ = ['main'] from _pytest.core import main, UsageError, _preloadplugins diff --git a/setup.py b/setup.py index b17306fc5..72cf5f98c 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ def main(): name='pytest', description='py.test: simple powerful testing with Python', long_description = long_description, - version='2.0.3.dev2', + version='2.0.3.dev3', url='http://pytest.org', license='MIT license', platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], diff --git a/testing/test_junitxml.py b/testing/test_junitxml.py index 186f5c84b..4521ff1ac 100644 --- a/testing/test_junitxml.py +++ b/testing/test_junitxml.py @@ -58,6 +58,26 @@ class TestPython: assert_attr(fnode, message="test setup failure") assert "ValueError" in fnode.toxml() + def test_skip_contains_name_reason(self, testdir): + testdir.makepyfile(""" + import pytest + def test_skip(): + pytest.skip("hello23") + """) + result, dom = runandparse(testdir) + assert result.ret == 0 + node = dom.getElementsByTagName("testsuite")[0] + assert_attr(node, skips=1) + tnode = node.getElementsByTagName("testcase")[0] + assert_attr(tnode, + classname="test_skip_contains_name_reason", + name="test_skip") + snode = tnode.getElementsByTagName("skipped")[0] + assert_attr(snode, + type="pytest.skip", + message="hello23", + ) + def test_classname_instance(self, testdir): testdir.makepyfile(""" class TestClass: