]> granicus.if.org Git - python/commitdiff
In unconditional except clauses, don't catch KeyboardInterrupt -- it's
authorGuido van Rossum <guido@python.org>
Fri, 7 Dec 2001 03:39:34 +0000 (03:39 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 7 Dec 2001 03:39:34 +0000 (03:39 +0000)
annoying that often you have to hit ^C numerous times before it
works.  The solution: before the "except:" clause, insert "except
KeyboardInterrupt: raise".  This propagates KeyboardInterrupt out,
stopping the test in its tracks.

Lib/unittest.py

index 7de4d6c63c434542b02bf822d3bf1d53d7cbeba6..3f59916760da3e23b9a2f152c3869d419f07e3fc 100644 (file)
@@ -202,6 +202,8 @@ class TestCase:
         try:
             try:
                 self.setUp()
+            except KeyboardInterrupt:
+                raise
             except:
                 result.addError(self, self.__exc_info())
                 return
@@ -212,11 +214,15 @@ class TestCase:
                 ok = 1
             except self.failureException, e:
                 result.addFailure(self, self.__exc_info())
+            except KeyboardInterrupt:
+                raise
             except:
                 result.addError(self, self.__exc_info())
 
             try:
                 self.tearDown()
+            except KeyboardInterrupt:
+                raise
             except:
                 result.addError(self, self.__exc_info())
                 ok = 0