aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_cmd_line.py
diff options
context:
space:
mode:
authorYilei Yang <yileiyang@google.com>2023-11-01 13:39:31 -0700
committerGitHub <noreply@github.com>2023-11-01 20:39:31 +0000
commit45a36d5f569fc50d37c2d4ca1ea0c611ebc40379 (patch)
tree0811a2cd4e499437446e7844b145065d85030e3b /Lib/test/test_cmd_line.py
parent7e135a48d619407cd4b2a6d80a4ce204b2f5f938 (diff)
downloadcpython-45a36d5f569fc50d37c2d4ca1ea0c611ebc40379.tar.gz
cpython-45a36d5f569fc50d37c2d4ca1ea0c611ebc40379.zip
gh-111374: Add a new PYTHON_FROZEN_MODULES env var, equivalent of `-X frozen_modules`. (#111411)
Adds a new PYTHON_FROZEN_MODULES env var to correspond with -X frozen_modules. Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Diffstat (limited to 'Lib/test/test_cmd_line.py')
-rw-r--r--Lib/test/test_cmd_line.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py
index 866c7d11000..2e57e4e5b49 100644
--- a/Lib/test/test_cmd_line.py
+++ b/Lib/test/test_cmd_line.py
@@ -153,6 +153,17 @@ class CmdLineTest(unittest.TestCase):
res = assert_python_ok(*cmd)
self.assertRegex(res.out.decode('utf-8'), expected)
+ def test_env_var_frozen_modules(self):
+ tests = {
+ ('on', 'FrozenImporter'),
+ ('off', 'SourceFileLoader'),
+ }
+ for raw, expected in tests:
+ cmd = ['-c', 'import os; print(os.__spec__.loader, end="")']
+ with self.subTest(raw):
+ res = assert_python_ok(*cmd, PYTHON_FROZEN_MODULES=raw)
+ self.assertRegex(res.out.decode('utf-8'), expected)
+
def test_run_module(self):
# Test expected operation of the '-m' switch
# Switch needs an argument