[Zope3-checkins] SVN: zope.testing/tags/regebro-python3-reloaded/src/zope/testing/doctest.py Make sure we get the exception printed under Python 3 too.

Lennart Regebro regebro at gmail.com
Mon Dec 7 14:22:43 EST 2009


Log message for revision 106254:
  Make sure we get the exception printed under Python 3 too.
  

Changed:
  U   zope.testing/tags/regebro-python3-reloaded/src/zope/testing/doctest.py

-=-
Modified: zope.testing/tags/regebro-python3-reloaded/src/zope/testing/doctest.py
===================================================================
--- zope.testing/tags/regebro-python3-reloaded/src/zope/testing/doctest.py	2009-12-07 18:56:38 UTC (rev 106253)
+++ zope.testing/tags/regebro-python3-reloaded/src/zope/testing/doctest.py	2009-12-07 19:22:43 UTC (rev 106254)
@@ -283,7 +283,7 @@
             del self.softspace
 
     def write(self, value):
-        if isinstance(value, unicode):
+        if not isinstance(value, str):
             value = value.encode('utf8')
         StringIO.write(self, value)
 
@@ -1376,11 +1376,11 @@
                 exec compile(example.source, filename, "single",
                              compileflags, 1) in test.globs
                 self.debugger.set_continue() # ==== Example Finished ====
-                exception = None
+                exc_info = None
             except KeyboardInterrupt:
                 raise
             except:
-                exception = sys.exc_info()
+                exc_info = sys.exc_info()
                 self.debugger.set_continue() # ==== Example Finished ====
             got = self._fakeout.getvalue()  # the actual output
             self._fakeout.truncate(0)
@@ -1388,13 +1388,12 @@
 
             # If the example executed without raising any exceptions,
             # verify its output.
-            if exception is None:
+            if exc_info is None:
                 if check(example.want, got, self.optionflags):
                     outcome = SUCCESS
 
             # The example raised an exception:  check if it was expected.
             else:
-                exc_info = sys.exc_info()
                 exc_msg = traceback.format_exception_only(*exc_info[:2])[-1]
                 if not quiet:
                     got += _exception_traceback(exc_info)
@@ -1402,6 +1401,7 @@
                 # If `example.exc_msg` is None, then we weren't expecting
                 # an exception.
                 if example.exc_msg is None:
+                    #print self.optionflags & IGNORE_EXCEPTION_DETAIL
                     outcome = BOOM
 
                 # We expected an exception:  see whether it matches.



More information about the Zope3-Checkins mailing list