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

Side by Side Diff: Lib/test/test_faulthandler.py

Issue 23670: Modifications to support iOS as a development platform
Patch Set: Created 3 years, 8 months ago
Left:
Right:
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 unified diff | Download patch
« no previous file with comments | « Lib/test/test_doctest.py ('k') | Lib/test/test_fcntl.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 from contextlib import contextmanager 1 from contextlib import contextmanager
2 import datetime 2 import datetime
3 import faulthandler 3 import faulthandler
4 import os 4 import os
5 import re 5 import re
6 import signal 6 import signal
7 import subprocess 7 import subprocess
8 import sys 8 import sys
9 from test import support 9 from test import support
10 from test.support import script_helper 10 from test.support import script_helper
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 faulthandler.disable() 275 faulthandler.disable()
276 self.assertFalse(faulthandler.is_enabled()) 276 self.assertFalse(faulthandler.is_enabled())
277 finally: 277 finally:
278 if was_enabled: 278 if was_enabled:
279 faulthandler.enable() 279 faulthandler.enable()
280 else: 280 else:
281 faulthandler.disable() 281 faulthandler.disable()
282 finally: 282 finally:
283 sys.stderr = orig_stderr 283 sys.stderr = orig_stderr
284 284
285 @unittest.skipUnless(hasattr(subprocess, 'Popen'), "test requires subprocess .Popen()")
285 def test_disabled_by_default(self): 286 def test_disabled_by_default(self):
286 # By default, the module should be disabled 287 # By default, the module should be disabled
287 code = "import faulthandler; print(faulthandler.is_enabled())" 288 code = "import faulthandler; print(faulthandler.is_enabled())"
288 args = filter(None, (sys.executable, 289 args = filter(None, (sys.executable,
289 "-E" if sys.flags.ignore_environment else "", 290 "-E" if sys.flags.ignore_environment else "",
290 "-c", code)) 291 "-c", code))
291 env = os.environ.copy() 292 env = os.environ.copy()
292 env.pop("PYTHONFAULTHANDLER", None) 293 env.pop("PYTHONFAULTHANDLER", None)
293 # don't use assert_python_ok() because it always enables faulthandler 294 # don't use assert_python_ok() because it always enables faulthandler
294 output = subprocess.check_output(args, env=env) 295 output = subprocess.check_output(args, env=env)
295 self.assertEqual(output.rstrip(), b"False") 296 self.assertEqual(output.rstrip(), b"False")
296 297
298 @unittest.skipUnless(hasattr(subprocess, 'Popen'), "test requires subprocess .Popen()")
297 def test_sys_xoptions(self): 299 def test_sys_xoptions(self):
298 # Test python -X faulthandler 300 # Test python -X faulthandler
299 code = "import faulthandler; print(faulthandler.is_enabled())" 301 code = "import faulthandler; print(faulthandler.is_enabled())"
300 args = filter(None, (sys.executable, 302 args = filter(None, (sys.executable,
301 "-E" if sys.flags.ignore_environment else "", 303 "-E" if sys.flags.ignore_environment else "",
302 "-X", "faulthandler", "-c", code)) 304 "-X", "faulthandler", "-c", code))
303 env = os.environ.copy() 305 env = os.environ.copy()
304 env.pop("PYTHONFAULTHANDLER", None) 306 env.pop("PYTHONFAULTHANDLER", None)
305 # don't use assert_python_ok() because it always enables faulthandler 307 # don't use assert_python_ok() because it always enables faulthandler
306 output = subprocess.check_output(args, env=env) 308 output = subprocess.check_output(args, env=env)
307 self.assertEqual(output.rstrip(), b"True") 309 self.assertEqual(output.rstrip(), b"True")
308 310
311 @unittest.skipUnless(hasattr(subprocess, 'Popen'), "test requires subprocess .Popen()")
309 def test_env_var(self): 312 def test_env_var(self):
310 # empty env var 313 # empty env var
311 code = "import faulthandler; print(faulthandler.is_enabled())" 314 code = "import faulthandler; print(faulthandler.is_enabled())"
312 args = (sys.executable, "-c", code) 315 args = (sys.executable, "-c", code)
313 env = os.environ.copy() 316 env = os.environ.copy()
314 env['PYTHONFAULTHANDLER'] = '' 317 env['PYTHONFAULTHANDLER'] = ''
315 # don't use assert_python_ok() because it always enables faulthandler 318 # don't use assert_python_ok() because it always enables faulthandler
316 output = subprocess.check_output(args, env=env) 319 output = subprocess.check_output(args, env=env)
317 self.assertEqual(output.rstrip(), b"False") 320 self.assertEqual(output.rstrip(), b"False")
318 321
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 if hasattr(faulthandler, 'dump_traceback_later'): 687 if hasattr(faulthandler, 'dump_traceback_later'):
685 with self.check_stderr_none(): 688 with self.check_stderr_none():
686 faulthandler.dump_traceback_later(1e-3) 689 faulthandler.dump_traceback_later(1e-3)
687 if hasattr(faulthandler, "register"): 690 if hasattr(faulthandler, "register"):
688 with self.check_stderr_none(): 691 with self.check_stderr_none():
689 faulthandler.register(signal.SIGUSR1) 692 faulthandler.register(signal.SIGUSR1)
690 693
691 694
692 if __name__ == "__main__": 695 if __name__ == "__main__":
693 unittest.main() 696 unittest.main()
OLDNEW
« no previous file with comments | « Lib/test/test_doctest.py ('k') | Lib/test/test_fcntl.py » ('j') | no next file with comments »

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