[Zope3-checkins] SVN: zope.testing/branches/regebro-python3-reloaded/src/zope/testing/ Fixed the last failing (under 2.x) tests by monkey-patching doctest.py.

Lennart Regebro regebro at gmail.com
Wed Dec 9 11:28:50 EST 2009


Log message for revision 106344:
  Fixed the last failing (under 2.x) tests by monkey-patching doctest.py.
  

Changed:
  A   zope.testing/branches/regebro-python3-reloaded/src/zope/testing/monkeys.py
  U   zope.testing/branches/regebro-python3-reloaded/src/zope/testing/testrunner/tests.py

-=-
Added: zope.testing/branches/regebro-python3-reloaded/src/zope/testing/monkeys.py
===================================================================
--- zope.testing/branches/regebro-python3-reloaded/src/zope/testing/monkeys.py	                        (rev 0)
+++ zope.testing/branches/regebro-python3-reloaded/src/zope/testing/monkeys.py	2009-12-09 16:28:50 UTC (rev 106344)
@@ -0,0 +1,35 @@
+import sys
+import doctest
+import unittest
+
+def new_init(self, test, optionflags=0, setUp=None, tearDown=None,
+             checker=None):
+    unittest.TestCase.__init__(self)
+    self._dt_optionflags = optionflags
+    self._dt_checker = checker
+    self._dt_test = test
+    self._dt_setUp = setUp
+    self._dt_tearDown = tearDown
+    self._dt_globs = test.globs.copy()
+
+def new_tearDown(self):
+    test = self._dt_test
+
+    if self._dt_tearDown is not None:
+        self._dt_tearDown(test)
+
+    test.globs.clear()
+    test.globs.update(self._dt_globs)
+
+doctest.DocTestCase.__init__ = new_init
+doctest.DocTestCase.tearDown = new_tearDown
+
+if sys.version_info < (3,):
+    from StringIO import StringIO
+    
+    def new_write(self, value):
+        if isinstance(value, unicode):
+            value = value.encode('utf8')
+        StringIO.write(self, value)
+    
+    doctest._SpoofOut.write = new_write

Modified: zope.testing/branches/regebro-python3-reloaded/src/zope/testing/testrunner/tests.py
===================================================================
--- zope.testing/branches/regebro-python3-reloaded/src/zope/testing/testrunner/tests.py	2009-12-09 16:04:08 UTC (rev 106343)
+++ zope.testing/branches/regebro-python3-reloaded/src/zope/testing/testrunner/tests.py	2009-12-09 16:28:50 UTC (rev 106344)
@@ -160,7 +160,7 @@
         'testrunner-test-selection.txt',
         'testrunner-verbose.txt',
         'testrunner-wo-source.txt',
-        #'testrunner-repeat.txt',
+        'testrunner-repeat.txt',
         'testrunner-gc.txt',
         'testrunner-knit.txt',
         setUp=setUp, tearDown=tearDown,



More information about the Zope3-Checkins mailing list