summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_faulthandler.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-07-21 10:30:22 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2014-07-21 10:30:22 (GMT)
commit56e8c29a4e5f5907e2e170e23d9a57e564401a75 (patch)
tree9d5e7dd32897d3380b85093d456f464d3ad7b577 /Lib/test/test_faulthandler.py
parent569a7fa13a1a69b070e9aff9a5fdc065960e4db1 (diff)
downloadcpython-56e8c29a4e5f5907e2e170e23d9a57e564401a75.zip
cpython-56e8c29a4e5f5907e2e170e23d9a57e564401a75.tar.gz
cpython-56e8c29a4e5f5907e2e170e23d9a57e564401a75.tar.bz2
Issue #22018: Add _testcapi.raise_signal()
- Use _testcapi.raise_signal() in test_signal - close also os.pipe() file descriptors in some test_signal tests where they were not closed properly - Remove faulthandler._sigill() and faulthandler._sigbus(): reuse _testcapi.raise_signal() in test_faulthandler
Diffstat (limited to 'Lib/test/test_faulthandler.py')
-rw-r--r--Lib/test/test_faulthandler.py26
1 files changed, 18 insertions, 8 deletions
diff --git a/Lib/test/test_faulthandler.py b/Lib/test/test_faulthandler.py
index b0fc279..f514f57 100644
--- a/Lib/test/test_faulthandler.py
+++ b/Lib/test/test_faulthandler.py
@@ -16,6 +16,10 @@ try:
HAVE_THREADS = True
except ImportError:
HAVE_THREADS = False
+try:
+ import _testcapi
+except ImportError:
+ _testcapi = None
TIMEOUT = 0.5
@@ -133,26 +137,32 @@ faulthandler._sigfpe()
3,
'Floating point exception')
- @unittest.skipIf(not hasattr(faulthandler, '_sigbus'),
- "need faulthandler._sigbus()")
+ @unittest.skipIf(_testcapi is None, 'need _testcapi')
+ @unittest.skipUnless(hasattr(signal, 'SIGBUS'), 'need signal.SIGBUS')
def test_sigbus(self):
self.check_fatal_error("""
+import _testcapi
import faulthandler
+import signal
+
faulthandler.enable()
-faulthandler._sigbus()
+_testcapi.raise_signal(signal.SIGBUS)
""".strip(),
- 3,
+ 6,
'Bus error')
- @unittest.skipIf(not hasattr(faulthandler, '_sigill'),
- "need faulthandler._sigill()")
+ @unittest.skipIf(_testcapi is None, 'need _testcapi')
+ @unittest.skipUnless(hasattr(signal, 'SIGILL'), 'need signal.SIGILL')
def test_sigill(self):
self.check_fatal_error("""
+import _testcapi
import faulthandler
+import signal
+
faulthandler.enable()
-faulthandler._sigill()
+_testcapi.raise_signal(signal.SIGILL)
""".strip(),
- 3,
+ 6,
'Illegal instruction')
def test_fatal_error(self):