diff options
author | Michael Foord <fuzzyman@voidspace.org.uk> | 2010-04-25 19:53:49 (GMT) |
---|---|---|
committer | Michael Foord <fuzzyman@voidspace.org.uk> | 2010-04-25 19:53:49 (GMT) |
commit | de4ceabfd8b9cf357332e7fa1bfb46c157402efa (patch) | |
tree | 838eeb9e95f3f72beeb754e17c6f20c9dc8ff24b /Lib/unittest/test | |
parent | af30c5d32e52ec61cb9964dcb44f9b7eae82cfa9 (diff) | |
download | cpython-de4ceabfd8b9cf357332e7fa1bfb46c157402efa.zip cpython-de4ceabfd8b9cf357332e7fa1bfb46c157402efa.tar.gz cpython-de4ceabfd8b9cf357332e7fa1bfb46c157402efa.tar.bz2 |
Merged revisions 80476 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r80476 | michael.foord | 2010-04-25 20:02:46 +0100 (Sun, 25 Apr 2010) | 1 line
Adding unittest.removeHandler function / decorator for removing the signal.SIGINT signal handler. With tests and docs.
........
Diffstat (limited to 'Lib/unittest/test')
-rw-r--r-- | Lib/unittest/test/test_break.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/unittest/test/test_break.py b/Lib/unittest/test/test_break.py index 4f89e87..0e09dfb 100644 --- a/Lib/unittest/test/test_break.py +++ b/Lib/unittest/test/test_break.py @@ -227,3 +227,24 @@ class TestBreak(unittest.TestCase): self.assertEqual(p.result, result) self.assertNotEqual(signal.getsignal(signal.SIGINT), default_handler) + + def testRemoveHandler(self): + default_handler = signal.getsignal(signal.SIGINT) + unittest.installHandler() + unittest.removeHandler() + self.assertEqual(signal.getsignal(signal.SIGINT), default_handler) + + # check that calling removeHandler multiple times has no ill-effect + unittest.removeHandler() + self.assertEqual(signal.getsignal(signal.SIGINT), default_handler) + + def testRemoveHandlerAsDecorator(self): + default_handler = signal.getsignal(signal.SIGINT) + unittest.installHandler() + + @unittest.removeHandler + def test(): + self.assertEqual(signal.getsignal(signal.SIGINT), default_handler) + + test() + self.assertNotEqual(signal.getsignal(signal.SIGINT), default_handler) |