Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(2)

Unified Diff: Lib/test/test_faulthandler.py

Issue 10639: reindent.py converts newlines to platform default
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Lib/test/test_extcall.py ('k') | Lib/test/test_fcntl.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/test/test_faulthandler.py Tue Jul 26 09:37:46 2011 +0300
+++ b/Lib/test/test_faulthandler.py Mon Jul 25 09:47:18 2011 -0400
@@ -1,7 +1,6 @@
from contextlib import contextmanager
import datetime
import faulthandler
-import os
import re
import signal
import subprocess
@@ -231,26 +230,17 @@
self.assertNotEqual(exitcode, 0)
def test_is_enabled(self):
- orig_stderr = sys.stderr
+ was_enabled = faulthandler.is_enabled()
try:
- # regrtest may replace sys.stderr by io.StringIO object, but
- # faulthandler.enable() requires that sys.stderr has a fileno()
- # method
- sys.stderr = sys.__stderr__
-
- was_enabled = faulthandler.is_enabled()
- try:
+ faulthandler.enable()
+ self.assertTrue(faulthandler.is_enabled())
+ faulthandler.disable()
+ self.assertFalse(faulthandler.is_enabled())
+ finally:
+ if was_enabled:
faulthandler.enable()
- self.assertTrue(faulthandler.is_enabled())
+ else:
faulthandler.disable()
- self.assertFalse(faulthandler.is_enabled())
- finally:
- if was_enabled:
- faulthandler.enable()
- else:
- faulthandler.disable()
- finally:
- sys.stderr = orig_stderr
def check_dump_traceback(self, filename):
"""
@@ -452,13 +442,11 @@
@unittest.skipIf(not hasattr(faulthandler, "register"),
"need faulthandler.register")
def check_register(self, filename=False, all_threads=False,
- unregister=False, chain=False):
+ unregister=False):
"""
Register a handler displaying the traceback on a user signal. Raise the
signal and check the written traceback.
- If chain is True, check that the previous signal handler is called.
-
Raise an error if the output doesn't match the expected format.
"""
signum = signal.SIGUSR1
@@ -466,41 +454,22 @@
import faulthandler
import os
import signal
-import sys
def func(signum):
os.kill(os.getpid(), signum)
-def handler(signum, frame):
- handler.called = True
-handler.called = False
-
-exitcode = 0
signum = {signum}
unregister = {unregister}
-chain = {chain}
-
if {has_filename}:
file = open({filename}, "wb")
else:
file = None
-if chain:
- signal.signal(signum, handler)
-faulthandler.register(signum, file=file,
- all_threads={all_threads}, chain={chain})
+faulthandler.register(signum, file=file, all_threads={all_threads})
if unregister:
faulthandler.unregister(signum)
func(signum)
-if chain and not handler.called:
- if file is not None:
- output = file
- else:
- output = sys.stderr
- print("Error: signal handler not called!", file=output)
- exitcode = 1
if file is not None:
file.close()
-sys.exit(exitcode)
""".strip()
code = code.format(
filename=repr(filename),
@@ -508,7 +477,6 @@
all_threads=all_threads,
signum=signum,
unregister=unregister,
- chain=chain,
)
trace, exitcode = self.get_output(code, filename)
trace = '\n'.join(trace)
@@ -517,7 +485,7 @@
regex = 'Current thread XXX:\n'
else:
regex = 'Traceback \(most recent call first\):\n'
- regex = expected_traceback(7, 28, regex)
+ regex = expected_traceback(6, 17, regex)
self.assertRegex(trace, regex)
else:
self.assertEqual(trace, '')
@@ -539,9 +507,6 @@
def test_register_threads(self):
self.check_register(all_threads=True)
- def test_register_chain(self):
- self.check_register(chain=True)
-
def test_main():
support.run_unittest(FaultHandlerTests)
« no previous file with comments | « Lib/test/test_extcall.py ('k') | Lib/test/test_fcntl.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+