[Zope3-checkins] SVN: Zope3/trunk/src/zope/importtool/tests/test_hook.py add a test that exceptions raised by the exception callback override the original exception

Fred L. Drake, Jr. fred at zope.com
Wed Jun 2 15:37:55 EDT 2004


Log message for revision 25200:
add a test that exceptions raised by the exception callback override the original exception


-=-
Modified: Zope3/trunk/src/zope/importtool/tests/test_hook.py
===================================================================
--- Zope3/trunk/src/zope/importtool/tests/test_hook.py	2004-06-02 19:31:48 UTC (rev 25199)
+++ Zope3/trunk/src/zope/importtool/tests/test_hook.py	2004-06-02 19:37:55 UTC (rev 25200)
@@ -41,6 +41,12 @@
         raise TestException("found")
 
 
+class ReporterRaiseOnException(reporter.Reporter):
+
+    def exception(self, *args):
+        raise TestException("exception")
+
+
 class ReporterRaiseOnRequest(reporter.Reporter):
 
     def request(self, *args):
@@ -147,6 +153,16 @@
         else:
             self.fail("expected TestException")
 
+    def test_exception_on_exception(self):
+        h = self.get_hook(ReporterRaiseOnException())
+        h.install()
+        try:
+            import zope.importtools.tests.does_not_exist
+        except TestException, e:
+            self.assertEqual(e[0], "exception")
+        else:
+            self.fail("expected TestException")
+
     def test_direct_calls(self):
         # make sure the hook function can be called directly as well,
         # and behave the way the default __import__() works




More information about the Zope3-Checkins mailing list