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

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

Issue 16510: Using appropriate checks in tests
Patch Set: Created 5 years, 6 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_capi.py ('k') | Lib/test/test_codeop.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 shutil 7 import shutil
8 import sys 8 import sys
9 import subprocess 9 import subprocess
10 import tempfile 10 import tempfile
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 assert_python_ok('-m', 'timeit', '-n', '1') 113 assert_python_ok('-m', 'timeit', '-n', '1')
114 114
115 def test_run_module_bug1764407(self): 115 def test_run_module_bug1764407(self):
116 # -m and -i need to play well together 116 # -m and -i need to play well together
117 # Runs the timeit module and checks the __main__ 117 # Runs the timeit module and checks the __main__
118 # namespace has been populated appropriately 118 # namespace has been populated appropriately
119 p = spawn_python('-i', '-m', 'timeit', '-n', '1') 119 p = spawn_python('-i', '-m', 'timeit', '-n', '1')
120 p.stdin.write(b'Timer\n') 120 p.stdin.write(b'Timer\n')
121 p.stdin.write(b'exit()\n') 121 p.stdin.write(b'exit()\n')
122 data = kill_python(p) 122 data = kill_python(p)
123 self.assertTrue(data.find(b'1 loop') != -1) 123 self.assertNotEqual(data.find(b'1 loop'), -1)
124 self.assertTrue(data.find(b'__main__.Timer') != -1) 124 self.assertNotEqual(data.find(b'__main__.Timer'), -1)
125 125
126 def test_run_code(self): 126 def test_run_code(self):
127 # Test expected operation of the '-c' switch 127 # Test expected operation of the '-c' switch
128 # Switch needs an argument 128 # Switch needs an argument
129 assert_python_failure('-c') 129 assert_python_failure('-c')
130 # Check we get an error for an uncaught exception 130 # Check we get an error for an uncaught exception
131 assert_python_failure('-c', 'raise Exception') 131 assert_python_failure('-c', 'raise Exception')
132 # All good if execution is successful 132 # All good if execution is successful
133 assert_python_ok('-c', 'pass') 133 assert_python_ok('-c', 'pass')
134 134
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 out = subprocess.check_output([sys.executable, "-I", main], 464 out = subprocess.check_output([sys.executable, "-I", main],
465 cwd=tmpdir) 465 cwd=tmpdir)
466 self.assertEqual(out.strip(), b"ok") 466 self.assertEqual(out.strip(), b"ok")
467 467
468 def test_main(): 468 def test_main():
469 test.support.run_unittest(CmdLineTest) 469 test.support.run_unittest(CmdLineTest)
470 test.support.reap_children() 470 test.support.reap_children()
471 471
472 if __name__ == "__main__": 472 if __name__ == "__main__":
473 test_main() 473 test_main()
OLDNEW
« no previous file with comments | « Lib/test/test_capi.py ('k') | Lib/test/test_codeop.py » ('j') | no next file with comments »

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