summaryrefslogtreecommitdiff
path: root/Lib/unittest.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-12-07 03:39:34 +0000
committerGuido van Rossum <guido@python.org>2001-12-07 03:39:34 +0000
commit202dd1ef420359c05814cbfcc5c27e71c90c16d9 (patch)
treedccbd6b3eef7f95d467647384cc6eb3cc361879b /Lib/unittest.py
parenteb4b7bad336481a34b2db01cbea809de726f9698 (diff)
downloadcpython-git-202dd1ef420359c05814cbfcc5c27e71c90c16d9.tar.gz
In unconditional except clauses, don't catch KeyboardInterrupt -- it's
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.
Diffstat (limited to 'Lib/unittest.py')
-rw-r--r--Lib/unittest.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/unittest.py b/Lib/unittest.py
index 7de4d6c63c..3f59916760 100644
--- a/Lib/unittest.py
+++ b/Lib/unittest.py
@@ -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