summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_cmd_line.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2022-05-06 01:41:24 (GMT)
committerGitHub <noreply@github.com>2022-05-06 01:41:24 (GMT)
commit329afe78c3bbc234492a53f7a4084d07e215a077 (patch)
tree281fa4038479d8d6e92bfa1da96ce18aca56a8f5 /Lib/test/test_cmd_line.py
parent1303f8c927227b72d9ee9eae890be4692b4d4592 (diff)
downloadcpython-329afe78c3bbc234492a53f7a4084d07e215a077.zip
cpython-329afe78c3bbc234492a53f7a4084d07e215a077.tar.gz
cpython-329afe78c3bbc234492a53f7a4084d07e215a077.tar.bz2
gh-57684: Update tests for PYTHONSAFEPATH=1 (#92358)
Fix tests failing with the PYTHONSAFEPATH=1 env var. Enhance also -P help in Python usage (python --help).
Diffstat (limited to 'Lib/test/test_cmd_line.py')
-rw-r--r--Lib/test/test_cmd_line.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py
index 2650631..5a9e14b 100644
--- a/Lib/test/test_cmd_line.py
+++ b/Lib/test/test_cmd_line.py
@@ -363,6 +363,8 @@ class CmdLineTest(unittest.TestCase):
self.assertIn(path1.encode('ascii'), out)
self.assertIn(path2.encode('ascii'), out)
+ @unittest.skipIf(sys.flags.safe_path,
+ 'PYTHONSAFEPATH changes default sys.path')
def test_empty_PYTHONPATH_issue16309(self):
# On Posix, it is documented that setting PATH to the
# empty string is equivalent to not setting PATH at all,
@@ -594,9 +596,10 @@ class CmdLineTest(unittest.TestCase):
with open(main, "w", encoding="utf-8") as f:
f.write("import uuid\n")
f.write("print('ok')\n")
+ # Use -E to ignore PYTHONSAFEPATH env var
self.assertRaises(subprocess.CalledProcessError,
subprocess.check_output,
- [sys.executable, main], cwd=tmpdir,
+ [sys.executable, '-E', main], cwd=tmpdir,
stderr=subprocess.DEVNULL)
out = subprocess.check_output([sys.executable, "-I", main],
cwd=tmpdir)