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

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

Issue 18338: python --version should send output to STDOUT
Patch Set: Created 6 years, 5 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 | « no previous file | Modules/main.c » ('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 22 matching lines...) Expand all
33 self.verify_valid_flag('-OO') 33 self.verify_valid_flag('-OO')
34 34
35 def test_site_flag(self): 35 def test_site_flag(self):
36 self.verify_valid_flag('-S') 36 self.verify_valid_flag('-S')
37 37
38 def test_usage(self): 38 def test_usage(self):
39 rc, out, err = assert_python_ok('-h') 39 rc, out, err = assert_python_ok('-h')
40 self.assertIn(b'usage', out) 40 self.assertIn(b'usage', out)
41 41
42 def test_version(self): 42 def test_version(self):
43 version = ('Python %d.%d' % sys.version_info[:2]).encode("ascii") 43 version = ('Python %d.%d' % sys.version_info[:2]).encode('ascii')
storchaka 2013/07/03 12:37:02 This is unrelated change.
44 rc, out, err = assert_python_ok('-V') 44 for cmd in ('-V', '--version'):
45 self.assertTrue(err.startswith(version)) 45 output = assert_python_ok(cmd)[1]
46 self.assertTrue(output.startswith(version))
46 47
47 def test_verbose(self): 48 def test_verbose(self):
48 # -v causes imports to write to stderr. If the write to 49 # -v causes imports to write to stderr. If the write to
49 # stderr itself causes an import to happen (for the output 50 # stderr itself causes an import to happen (for the output
50 # codec), a recursion loop can occur. 51 # codec), a recursion loop can occur.
51 rc, out, err = assert_python_ok('-v') 52 rc, out, err = assert_python_ok('-v')
52 self.assertNotIn(b'stack overflow', err) 53 self.assertNotIn(b'stack overflow', err)
53 rc, out, err = assert_python_ok('-vv') 54 rc, out, err = assert_python_ok('-vv')
54 self.assertNotIn(b'stack overflow', err) 55 self.assertNotIn(b'stack overflow', err)
55 56
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 self.assertEqual(err.splitlines().count(b'Unknown option: -a'), 1) 437 self.assertEqual(err.splitlines().count(b'Unknown option: -a'), 1)
437 self.assertEqual(b'', out) 438 self.assertEqual(b'', out)
438 439
439 440
440 def test_main(): 441 def test_main():
441 test.support.run_unittest(CmdLineTest) 442 test.support.run_unittest(CmdLineTest)
442 test.support.reap_children() 443 test.support.reap_children()
443 444
444 if __name__ == "__main__": 445 if __name__ == "__main__":
445 test_main() 446 test_main()
OLDNEW
« no previous file with comments | « no previous file | Modules/main.c » ('j') | no next file with comments »

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