summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_cmd_line.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-11-09 21:33:55 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-11-09 21:33:55 (GMT)
commit9bc35682de4911ea917f1016cc5fd67d3d1be97e (patch)
tree47d1727afe761d9f0e6a6985ba7f7e6152570b5c /Lib/test/test_cmd_line.py
parente912f5ab7ada996e5d464c9a4f99638188744c18 (diff)
downloadcpython-9bc35682de4911ea917f1016cc5fd67d3d1be97e.zip
cpython-9bc35682de4911ea917f1016cc5fd67d3d1be97e.tar.gz
cpython-9bc35682de4911ea917f1016cc5fd67d3d1be97e.tar.bz2
Use script_helper in one more test
Diffstat (limited to 'Lib/test/test_cmd_line.py')
-rw-r--r--Lib/test/test_cmd_line.py42
1 files changed, 14 insertions, 28 deletions
diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py
index e8f8c9d..e1fe7f5 100644
--- a/Lib/test/test_cmd_line.py
+++ b/Lib/test/test_cmd_line.py
@@ -5,18 +5,8 @@
import test.support, unittest
import os
import sys
-from test.script_helper import spawn_python, kill_python, assert_python_ok, assert_python_failure
-
-# spawn_python normally enforces use of -E to avoid environmental effects
-# but one test checks PYTHONPATH behaviour explicitly
-# XXX (ncoghlan): Give script_helper.spawn_python an option to switch
-# off the -E flag that is normally inserted automatically
import subprocess
-def _spawn_python_with_env(*args):
- cmd_line = [sys.executable]
- cmd_line.extend(args)
- return subprocess.Popen(cmd_line, stdin=subprocess.PIPE,
- stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+from test.script_helper import spawn_python, kill_python, assert_python_ok, assert_python_failure
# XXX (ncoghlan): Move to script_helper and make consistent with run_python
@@ -217,23 +207,19 @@ class CmdLineTest(unittest.TestCase):
self.assertTrue(data.startswith(b'x'), data)
def test_large_PYTHONPATH(self):
- with test.support.EnvironmentVarGuard() as env:
- path1 = "ABCDE" * 100
- path2 = "FGHIJ" * 100
- env['PYTHONPATH'] = path1 + os.pathsep + path2
-
- code = """
-import sys
-path = ":".join(sys.path)
-path = path.encode("ascii", "backslashreplace")
-sys.stdout.buffer.write(path)"""
- code = code.strip().splitlines()
- code = '; '.join(code)
- p = _spawn_python_with_env('-S', '-c', code)
- stdout, _ = p.communicate()
- p.stdout.close()
- self.assertIn(path1.encode('ascii'), stdout)
- self.assertIn(path2.encode('ascii'), stdout)
+ path1 = "ABCDE" * 100
+ path2 = "FGHIJ" * 100
+ path = path1 + os.pathsep + path2
+
+ code = """if 1:
+ import sys
+ path = ":".join(sys.path)
+ path = path.encode("ascii", "backslashreplace")
+ sys.stdout.buffer.write(path)"""
+ rc, out, err = assert_python_ok('-S', '-c', code,
+ PYTHONPATH=path)
+ self.assertIn(path1.encode('ascii'), out)
+ self.assertIn(path2.encode('ascii'), out)
def test_main():