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

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

Issue 16510: Using appropriate checks in tests
Patch Set: Created 7 years, 3 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_exceptions.py ('k') | Lib/test/test_filecmp.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, script_helper 9 from test import support, script_helper
10 from test.script_helper import assert_python_ok 10 from test.script_helper import assert_python_ok
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 def test_disable(self): 224 def test_disable(self):
225 code = """ 225 code = """
226 import faulthandler 226 import faulthandler
227 faulthandler.enable() 227 faulthandler.enable()
228 faulthandler.disable() 228 faulthandler.disable()
229 faulthandler._read_null() 229 faulthandler._read_null()
230 """.strip() 230 """.strip()
231 not_expected = 'Fatal Python error' 231 not_expected = 'Fatal Python error'
232 stderr, exitcode = self.get_output(code) 232 stderr, exitcode = self.get_output(code)
233 stder = '\n'.join(stderr) 233 stder = '\n'.join(stderr)
234 self.assertTrue(not_expected not in stderr, 234 self.assertNotIn(not_expected, stderr,
235 "%r is present in %r" % (not_expected, stderr)) 235 "%r is present in %r" % (not_expected, stderr))
236 self.assertNotEqual(exitcode, 0) 236 self.assertNotEqual(exitcode, 0)
237 237
238 def test_is_enabled(self): 238 def test_is_enabled(self):
239 orig_stderr = sys.stderr 239 orig_stderr = sys.stderr
240 try: 240 try:
241 # regrtest may replace sys.stderr by io.StringIO object, but 241 # regrtest may replace sys.stderr by io.StringIO object, but
242 # faulthandler.enable() requires that sys.stderr has a fileno() 242 # faulthandler.enable() requires that sys.stderr has a fileno()
243 # method 243 # method
244 sys.stderr = sys.__stderr__ 244 sys.stderr = sys.__stderr__
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 584
585 def test_register_chain(self): 585 def test_register_chain(self):
586 self.check_register(chain=True) 586 self.check_register(chain=True)
587 587
588 588
589 def test_main(): 589 def test_main():
590 support.run_unittest(FaultHandlerTests) 590 support.run_unittest(FaultHandlerTests)
591 591
592 if __name__ == "__main__": 592 if __name__ == "__main__":
593 test_main() 593 test_main()
OLDNEW
« no previous file with comments | « Lib/test/test_exceptions.py ('k') | Lib/test/test_filecmp.py » ('j') | no next file with comments »

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