def test_is_enabled(self):
orig_stderr = sys.stderr
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()
else:
faulthandler.disable()
finally:
sys.stderr = orig_stderr
评论列表
文章目录