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

Unified Diff: Lib/test/test_cmd_line.py

Issue 23670: Modifications to support iOS as a development platform
Patch Set: Created 4 years, 3 months ago
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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Lib/test/test_capi.py ('k') | Lib/test/test_doctest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/test/test_cmd_line.py Tue Mar 01 10:26:10 2016 +0200
+++ b/Lib/test/test_cmd_line.py Wed Mar 02 00:01:35 2016 +0000
@@ -52,32 +52,34 @@ class CmdLineTest(unittest.TestCase):
# -v causes imports to write to stderr. If the write to
# stderr itself causes an import to happen (for the output
# codec), a recursion loop can occur.
rc, out, err = assert_python_ok('-v')
self.assertNotIn(b'stack overflow', err)
rc, out, err = assert_python_ok('-vv')
self.assertNotIn(b'stack overflow', err)
+ @unittest.skipUnless(hasattr(subprocess, 'Popen'), "test requires subprocess.Popen()")
def test_xoptions(self):
def get_xoptions(*args):
# use subprocess module directly because test.support.script_helper adds
# "-X faulthandler" to the command line
args = (sys.executable, '-E') + args
args += ('-c', 'import sys; print(sys._xoptions)')
out = subprocess.check_output(args)
opts = eval(out.splitlines()[0])
return opts
opts = get_xoptions()
self.assertEqual(opts, {})
opts = get_xoptions('-Xa', '-Xb=c,d=e')
self.assertEqual(opts, {'a': True, 'b': 'c,d=e'})
+ @unittest.skipUnless(hasattr(subprocess, 'Popen'), "test requires subprocess.Popen()")
def test_showrefcount(self):
def run_python(*args):
# this is similar to assert_python_ok but doesn't strip
# the refcount from stderr. It can be replaced once
# assert_python_ok stops doing that.
cmd = [sys.executable]
PIPE = subprocess.PIPE
@@ -141,16 +143,17 @@ class CmdLineTest(unittest.TestCase):
assert_python_ok('-c', command)
# On Windows, pass bytes to subprocess doesn't test how Python decodes the
# command line, but how subprocess does decode bytes to unicode. Python
# doesn't decode the command line because Windows provides directly the
# arguments as unicode (using wmain() instead of main()).
@unittest.skipIf(sys.platform == 'win32',
'Windows has a native unicode API')
+ @unittest.skipUnless(hasattr(subprocess, 'Popen'), "test requires subprocess.Popen()")
def test_undecodable_code(self):
undecodable = b"\xff"
env = os.environ.copy()
# Use C locale to get ascii for the locale encoding
env['LC_ALL'] = 'C'
code = (
b'import locale; '
b'print(ascii("' + undecodable + b'"), '
@@ -205,16 +208,17 @@ class CmdLineTest(unittest.TestCase):
text = (
b'\xff' # invalid byte
b'\xc3\xa9' # valid utf-8 character
b'\xc3\xff' # invalid byte sequence
b'\xed\xa0\x80' # lone surrogate character (invalid)
+ @unittest.skipUnless(hasattr(subprocess, 'Popen'), "test requires subprocess.Popen()")
def test_unbuffered_output(self):
# Test expected operation of the '-u' switch
for stream in ('stdout', 'stderr'):
# Binary is unbuffered
code = ("import os, sys; sys.%s.buffer.write(b'x'); os._exit(0)"
% stream)
rc, out, err = assert_python_ok('-u', '-c', code)
data = err if stream == 'stderr' else out
@@ -264,16 +268,17 @@ class CmdLineTest(unittest.TestCase):
path = path.encode("ascii", "backslashreplace")
rc1, out1, err1 = assert_python_ok('-c', code, PYTHONPATH="")
rc2, out2, err2 = assert_python_ok('-c', code, __isolated=False)
# regarding to Posix specification, outputs should be equal
# for empty and unset PYTHONPATH
self.assertEqual(out1, out2)
+ @unittest.skipUnless(hasattr(subprocess, 'Popen'), "test requires subprocess.Popen()")
def test_displayhook_unencodable(self):
for encoding in ('ascii', 'latin-1', 'utf-8'):
# We are testing a PYTHON environment variable here, so we can't
# use -E, -I, or script_helper (which uses them). So instead we do
# poor-man's isolation by deleting the PYTHON vars from env.
env = {key:value for (key,value) in os.environ.copy().items()
if not key.startswith('PYTHON')}
env['PYTHONIOENCODING'] = encoding
@@ -286,16 +291,17 @@ class CmdLineTest(unittest.TestCase):
# non-ascii, surrogate, non-BMP printable, non-BMP unprintable
text = "a=\xe9 b=\uDC80 c=\U00010000 d=\U0010FFFF"
p.stdin.write(ascii(text).encode('ascii') + b"\n")
data = kill_python(p)
escaped = repr(text).encode(encoding, 'backslashreplace')
self.assertIn(escaped, data)
+ @unittest.skipUnless(hasattr(subprocess, 'Popen'), "test requires subprocess.Popen()")
def check_input(self, code, expected):
with tempfile.NamedTemporaryFile("wb+") as stdin:
sep = os.linesep.encode('ASCII')
stdin.write(sep.join((b'abc', b'def')))
with subprocess.Popen(
(sys.executable, "-c", code),
@@ -359,16 +365,17 @@ class CmdLineTest(unittest.TestCase):
# not attempt to flush it at shutdown.
code = "import sys; sys.stdout.close()"
rc, out, err = assert_python_ok('-c', code)
self.assertEqual(b'', err)
# Issue #7111: Python should work without standard streams
@unittest.skipIf(os.name != 'posix', "test needs POSIX semantics")
+ @unittest.skipUnless(hasattr(subprocess, 'Popen'), "test requires subprocess.Popen()")
def _test_no_stdio(self, streams):
code = """if 1:
import os, sys
for i, s in enumerate({streams}):
if getattr(sys, s) is not None:
os._exit(i + 1)
def preexec():
« no previous file with comments | « Lib/test/test_capi.py ('k') | Lib/test/test_doctest.py » ('j') | no next file with comments »

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