[Zope3-checkins] SVN: zope.testing/branches/3.9/ LP #719369: An `Unexpected success`_ (concept intruduced in Python 2.7) is no longer handled as success but as failure. This is a workaround. The whole unexpected success concept might be implemented later.

Michael Howitz mh at gocept.com
Mon Feb 21 07:53:52 EST 2011


Log message for revision 120499:
  LP #719369: An `Unexpected success`_ (concept intruduced in Python 2.7) is no longer handled as success but as failure. This is a workaround. The whole unexpected success concept might be implemented later.
  (Adapted from zope.testrunner)
  

Changed:
  U   zope.testing/branches/3.9/CHANGES.txt
  U   zope.testing/branches/3.9/src/zope/testing/testrunner/runner.py
  A   zope.testing/branches/3.9/src/zope/testing/testrunner/testrunner-ex-719369/
  A   zope.testing/branches/3.9/src/zope/testing/testrunner/testrunner-ex-719369/sampletestsf.py
  A   zope.testing/branches/3.9/src/zope/testing/testrunner/testrunner-unexpected-success.txt
  U   zope.testing/branches/3.9/src/zope/testing/testrunner/tests.py

-=-
Modified: zope.testing/branches/3.9/CHANGES.txt
===================================================================
--- zope.testing/branches/3.9/CHANGES.txt	2011-02-21 12:53:04 UTC (rev 120498)
+++ zope.testing/branches/3.9/CHANGES.txt	2011-02-21 12:53:52 UTC (rev 120499)
@@ -4,7 +4,15 @@
 3.9.6 (unreleased)
 ==================
 
+- LP #719369: An `Unexpected success`_ (concept intruduced in Python 2.7) is
+  no longer handled as success but as failure. This is a workaround. The
+  whole unexpected success concept might be implemented later.
 
+.. _`Unexpected success`: http://www.voidspace.org.uk/python/articles/unittest2.shtml#more-skipping
+
+- Updated tests to run on Python 2.7, too.
+
+
 3.9.5 (2010-05-19)
 ==================
 

Modified: zope.testing/branches/3.9/src/zope/testing/testrunner/runner.py
===================================================================
--- zope.testing/branches/3.9/src/zope/testing/testrunner/runner.py	2011-02-21 12:53:04 UTC (rev 120498)
+++ zope.testing/branches/3.9/src/zope/testing/testrunner/runner.py	2011-02-21 12:53:52 UTC (rev 120499)
@@ -650,6 +650,10 @@
 
 class TestResult(unittest.TestResult):
 
+    # Handle unexpected success as failure:
+    # https://bugs.launchpad.net/zope.testrunner/+bug/719369
+    addUnexpectedSuccess = None
+
     def __init__(self, options, tests, layer_name=None):
         unittest.TestResult.__init__(self)
         self.options = options

Added: zope.testing/branches/3.9/src/zope/testing/testrunner/testrunner-ex-719369/sampletestsf.py
===================================================================
--- zope.testing/branches/3.9/src/zope/testing/testrunner/testrunner-ex-719369/sampletestsf.py	                        (rev 0)
+++ zope.testing/branches/3.9/src/zope/testing/testrunner/testrunner-ex-719369/sampletestsf.py	2011-02-21 12:53:52 UTC (rev 120499)
@@ -0,0 +1,22 @@
+##############################################################################
+#
+# Copyright (c) 2011 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+
+import unittest
+
+
+class TestUnexpectedSuccess(unittest.TestCase):
+
+    @unittest.expectedFailure
+    def test_ef(self):
+        pass


Property changes on: zope.testing/branches/3.9/src/zope/testing/testrunner/testrunner-ex-719369/sampletestsf.py
___________________________________________________________________
Added: svn:keywords
   + Id Rev Date
Added: svn:eol-style
   + native

Added: zope.testing/branches/3.9/src/zope/testing/testrunner/testrunner-unexpected-success.txt
===================================================================
--- zope.testing/branches/3.9/src/zope/testing/testrunner/testrunner-unexpected-success.txt	                        (rev 0)
+++ zope.testing/branches/3.9/src/zope/testing/testrunner/testrunner-unexpected-success.txt	2011-02-21 12:53:52 UTC (rev 120499)
@@ -0,0 +1,42 @@
+testrunner handling of unexpected success
+=========================================
+
+Python 2.7 introduced the concept of expectedFailures to unittest.
+See http://www.voidspace.org.uk/python/articles/unittest2.shtml#more-skipping
+
+Although testrunner is currently not able to hande unexpected successes
+correctly at least it does not report them as successes.
+
+
+This document has some edge-case examples to test various aspects of
+the test runner.
+
+Separating Python path and test directories
+-------------------------------------------
+
+The --path option defines a directory to be searched for tests *and* a
+directory to be added to Python's search path.  The --test-path option
+can be used when you want to set a test search path without also
+affecting the Python path:
+
+    >>> import os, sys
+    >>> directory_with_tests = os.path.join(this_directory, 'testrunner-ex-719369')
+
+    >>> from zope.testing import testrunner
+
+    >>> defaults = [
+    ...     '--path', directory_with_tests,
+    ...     '--tests-pattern', '^sampletestsf?$',
+    ...     ]
+    >>> sys.argv = ['test']
+    >>> testrunner.run_internal(defaults)
+    ... # doctest: +ELLIPSIS
+    Running zope.testing.testrunner.layer.UnitTests tests:
+      Set up zope.testing.testrunner.layer.UnitTests in N.NNN seconds.
+    Failure in test test_ef (sampletestsf.TestUnexpectedSuccess)
+    Traceback (most recent call last):
+    _UnexpectedSuccess
+      Ran 1 tests with 1 failures and 0 errors in N.NNN seconds.
+    Tearing down left over layers:
+      Tear down zope.testing.testrunner.layer.UnitTests in N.NNN seconds.
+    True


Property changes on: zope.testing/branches/3.9/src/zope/testing/testrunner/testrunner-unexpected-success.txt
___________________________________________________________________
Added: svn:keywords
   + Id Rev Date
Added: svn:eol-style
   + native

Modified: zope.testing/branches/3.9/src/zope/testing/testrunner/tests.py
===================================================================
--- zope.testing/branches/3.9/src/zope/testing/testrunner/tests.py	2011-02-21 12:53:04 UTC (rev 120498)
+++ zope.testing/branches/3.9/src/zope/testing/testrunner/tests.py	2011-02-21 12:53:52 UTC (rev 120499)
@@ -298,4 +298,12 @@
                     optionflags=doctest.ELLIPSIS + doctest.NORMALIZE_WHITESPACE,
                     checker=checker))
 
+    if sys.version_info[:3] >= (2,7,0):
+        # Python 2.7 adds support for unittest.expectedFailure
+        suites.append(doctest.DocFileSuite(
+            'testrunner-unexpected-success.txt',
+            setUp=setUp, tearDown=tearDown,
+            optionflags=doctest.ELLIPSIS+doctest.NORMALIZE_WHITESPACE,
+            checker=checker))
+
     return unittest.TestSuite(suites)



More information about the Zope3-Checkins mailing list