[py-svn] commit/pytest: hpk42: fix missing reason/name information for skipped tests

Bitbucket commits-noreply at bitbucket.org
Sat Mar 19 18:00:25 CET 2011


1 new changeset in pytest:

http://bitbucket.org/hpk42/pytest/changeset/5485ef79f4ad/
changeset:   r2191:5485ef79f4ad
user:        hpk42
date:        2011-03-19 17:59:07
summary:     fix missing reason/name information for skipped tests
affected #:  5 files (1.1 KB)

--- a/CHANGELOG	Wed Mar 16 19:05:28 2011 +0100
+++ b/CHANGELOG	Sat Mar 19 17:59:07 2011 +0100
@@ -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.
 


--- a/_pytest/junitxml.py	Wed Mar 16 19:05:28 2011 +0100
+++ b/_pytest/junitxml.py	Sat Mar 19 17:59:07 2011 +0100
@@ -106,7 +106,13 @@
                 '<skipped message="expected test failure">%s</skipped>',
                 report.keywords['xfail'])
         else:
-            self.appendlog("<skipped/>")
+            filename, lineno, skipreason = report.longrepr
+            if skipreason.startswith("Skipped: "):
+                skipreason = skipreason[9:]
+            self.appendlog('<skipped type="pytest.skip" '
+                           'message="%s">%s</skipped>',
+                skipreason, "%s:%s: %s" % report.longrepr,
+                )
         self._closetestcase()
         self.skipped += 1
 


--- a/pytest.py	Wed Mar 16 19:05:28 2011 +0100
+++ b/pytest.py	Sat Mar 19 17:59:07 2011 +0100
@@ -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


--- a/setup.py	Wed Mar 16 19:05:28 2011 +0100
+++ b/setup.py	Sat Mar 19 17:59:07 2011 +0100
@@ -22,7 +22,7 @@
         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'],


--- a/testing/test_junitxml.py	Wed Mar 16 19:05:28 2011 +0100
+++ b/testing/test_junitxml.py	Sat Mar 19 17:59:07 2011 +0100
@@ -58,6 +58,26 @@
         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:

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.



More information about the pytest-commit mailing list