summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_cmd_line.py
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2017-05-23 04:36:03 (GMT)
committerGitHub <noreply@github.com>2017-05-23 04:36:03 (GMT)
commit6b4be195cd8868b76eb6fbe166acc39beee8ce36 (patch)
treebbab44fad32c576b9eb7e4b83368e200adc33f00 /Lib/test/test_cmd_line.py
parentf9169ce6b48c7cc7cc62d9eb5e4ee1ac7066d14b (diff)
downloadcpython-6b4be195cd8868b76eb6fbe166acc39beee8ce36.zip
cpython-6b4be195cd8868b76eb6fbe166acc39beee8ce36.tar.gz
cpython-6b4be195cd8868b76eb6fbe166acc39beee8ce36.tar.bz2
bpo-22257: Small changes for PEP 432. (#1728)
PEP 432 specifies a number of large changes to interpreter startup code, including exposing a cleaner C-API. The major changes depend on a number of smaller changes. This patch includes all those smaller changes.
Diffstat (limited to 'Lib/test/test_cmd_line.py')
-rw-r--r--Lib/test/test_cmd_line.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py
index 958d282..5f96d61 100644
--- a/Lib/test/test_cmd_line.py
+++ b/Lib/test/test_cmd_line.py
@@ -485,8 +485,29 @@ class CmdLineTest(unittest.TestCase):
cwd=tmpdir)
self.assertEqual(out.strip(), b"ok")
+
+class IgnoreEnvironmentTest(unittest.TestCase):
+
+ def run_ignoring_vars(self, predicate, **env_vars):
+ # Runs a subprocess with -E set, even though we're passing
+ # specific environment variables
+ # Logical inversion to match predicate check to a zero return
+ # code indicating success
+ code = "import sys; sys.stderr.write(str(sys.flags)); sys.exit(not ({}))".format(predicate)
+ return assert_python_ok('-E', '-c', code, **env_vars)
+
+ def test_ignore_PYTHONPATH(self):
+ path = "should_be_ignored"
+ self.run_ignoring_vars("'{}' not in sys.path".format(path),
+ PYTHONPATH=path)
+
+ def test_ignore_PYTHONHASHSEED(self):
+ self.run_ignoring_vars("sys.flags.hash_randomization == 1",
+ PYTHONHASHSEED="0")
+
+
def test_main():
- test.support.run_unittest(CmdLineTest)
+ test.support.run_unittest(CmdLineTest, IgnoreEnvironmentTest)
test.support.reap_children()
if __name__ == "__main__":