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

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

Issue 16510: Using appropriate checks in tests
Patch Set: Created 7 years, 4 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_cgi.py ('k') | Lib/test/test_codecs.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 # Tests invocation of the interpreter with various command line arguments 1 # Tests invocation of the interpreter with various command line arguments
2 # Most tests are executed with environment variables ignored 2 # Most tests are executed with environment variables ignored
3 # See test_cmd_line_script.py for testing of script execution 3 # See test_cmd_line_script.py for testing of script execution
4 4
5 import test.support, unittest 5 import test.support, unittest
6 import os 6 import os
7 import sys 7 import sys
8 import subprocess 8 import subprocess
9 import tempfile 9 import tempfile
10 from test.script_helper import (spawn_python, kill_python, assert_python_ok, 10 from test.script_helper import (spawn_python, kill_python, assert_python_ok,
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 assert_python_ok('-m', 'timeit', '-n', '1'), 75 assert_python_ok('-m', 'timeit', '-n', '1'),
76 76
77 def test_run_module_bug1764407(self): 77 def test_run_module_bug1764407(self):
78 # -m and -i need to play well together 78 # -m and -i need to play well together
79 # Runs the timeit module and checks the __main__ 79 # Runs the timeit module and checks the __main__
80 # namespace has been populated appropriately 80 # namespace has been populated appropriately
81 p = spawn_python('-i', '-m', 'timeit', '-n', '1') 81 p = spawn_python('-i', '-m', 'timeit', '-n', '1')
82 p.stdin.write(b'Timer\n') 82 p.stdin.write(b'Timer\n')
83 p.stdin.write(b'exit()\n') 83 p.stdin.write(b'exit()\n')
84 data = kill_python(p) 84 data = kill_python(p)
85 self.assertTrue(data.find(b'1 loop') != -1) 85 self.assertNotEqual(data.find(b'1 loop'), -1)
86 self.assertTrue(data.find(b'__main__.Timer') != -1) 86 self.assertNotEqual(data.find(b'__main__.Timer'), -1)
87 87
88 def test_run_code(self): 88 def test_run_code(self):
89 # Test expected operation of the '-c' switch 89 # Test expected operation of the '-c' switch
90 # Switch needs an argument 90 # Switch needs an argument
91 assert_python_failure('-c') 91 assert_python_failure('-c')
92 # Check we get an error for an uncaught exception 92 # Check we get an error for an uncaught exception
93 assert_python_failure('-c', 'raise Exception') 93 assert_python_failure('-c', 'raise Exception')
94 # All good if execution is successful 94 # All good if execution is successful
95 assert_python_ok('-c', 'pass') 95 assert_python_ok('-c', 'pass')
96 96
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 self.assertIn(b'Unknown option', err) 393 self.assertIn(b'Unknown option', err)
394 self.assertEqual(err.splitlines().count(b'Unknown option: -z'), 1) 394 self.assertEqual(err.splitlines().count(b'Unknown option: -z'), 1)
395 self.assertEqual(b'', out) 395 self.assertEqual(b'', out)
396 396
397 def test_main(): 397 def test_main():
398 test.support.run_unittest(CmdLineTest) 398 test.support.run_unittest(CmdLineTest)
399 test.support.reap_children() 399 test.support.reap_children()
400 400
401 if __name__ == "__main__": 401 if __name__ == "__main__":
402 test_main() 402 test_main()
OLDNEW
« no previous file with comments | « Lib/test/test_cgi.py ('k') | Lib/test/test_codecs.py » ('j') | no next file with comments »

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