[Zope3-checkins] SVN: zope.testing/trunk/src/zope/testing/ found another unicode related bug which occured when one test returned a unicode and a subsequent test a normal string with unicode chars

Christian Zagrodnick cz at gocept.com
Wed May 23 13:30:17 EDT 2007


Log message for revision 75911:
  found another unicode related bug which occured when one test returned a unicode and a subsequent test a normal string with unicode chars

Changed:
  U   zope.testing/trunk/src/zope/testing/doctest.py
  U   zope.testing/trunk/src/zope/testing/testrunner-errors.txt
  U   zope.testing/trunk/src/zope/testing/testrunner-ex/unicode.txt

-=-
Modified: zope.testing/trunk/src/zope/testing/doctest.py
===================================================================
--- zope.testing/trunk/src/zope/testing/doctest.py	2007-05-23 15:37:21 UTC (rev 75910)
+++ zope.testing/trunk/src/zope/testing/doctest.py	2007-05-23 17:30:16 UTC (rev 75911)
@@ -282,6 +282,11 @@
         if hasattr(self, "softspace"):
             del self.softspace
 
+    def write(self, value):
+        if isinstance(value, unicode):
+            value = value.encode('utf8')
+        StringIO.write(self, value)
+
 # Worst-case linear-time ellipsis matching.
 def _ellipsis_match(want, got):
     """
@@ -1353,7 +1358,6 @@
             except:
                 exception = sys.exc_info()
                 self.debugger.set_continue() # ==== Example Finished ====
-
             got = self._fakeout.getvalue()  # the actual output
             self._fakeout.truncate(0)
             outcome = FAILURE   # guilty until proved innocent or insane

Modified: zope.testing/trunk/src/zope/testing/testrunner-errors.txt
===================================================================
--- zope.testing/trunk/src/zope/testing/testrunner-errors.txt	2007-05-23 15:37:21 UTC (rev 75910)
+++ zope.testing/trunk/src/zope/testing/testrunner-errors.txt	2007-05-23 17:30:16 UTC (rev 75911)
@@ -906,7 +906,7 @@
     Running tests at level 1
     Running unit tests:
       Running:
-    ..
+    ...
     <BLANKLINE>
     Failure testrunner-ex/unicode.txt
     Failed doctest test for unicode.txt
@@ -930,7 +930,7 @@
         'xyz'
     <BLANKLINE>
     <BLANKLINE>
-      Ran 2 tests with 1 failures and 0 errors in N.NNN seconds.
+      Ran 3 tests with 1 failures and 0 errors in N.NNN seconds.
     True
 
  

Modified: zope.testing/trunk/src/zope/testing/testrunner-ex/unicode.txt
===================================================================
--- zope.testing/trunk/src/zope/testing/testrunner-ex/unicode.txt	2007-05-23 15:37:21 UTC (rev 75910)
+++ zope.testing/trunk/src/zope/testing/testrunner-ex/unicode.txt	2007-05-23 17:30:16 UTC (rev 75911)
@@ -10,9 +10,18 @@
     >>> print get_unicode()
     oink
 
+There was another unicode bug. When a function returned unicode some internal
+state switched. This broke any further test not returning unicode but a plain
+string with unicode characters. Make sure this works now::
+
+    >>> get_unicode()
+    u'foo \u2014 bar'
+    >>> print get_unicode()
+    foo — bar
+
+
 Get some normal output as well::
 
     >>> 'xyz'
     123
 
-



More information about the Zope3-Checkins mailing list