diff options
author | Eric Snow <ericsnowcurrently@gmail.com> | 2021-10-25 21:26:41 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-25 21:26:41 (GMT) |
commit | 6afb285ff0790471a6858e44f85d143f07fda70c (patch) | |
tree | 4e8505fe17c108c8a58aecea7111775b59a66b29 /Lib/test/test_cmd_line.py | |
parent | 2b8677a3cd855eb3a579894c64588eab0e006269 (diff) | |
download | cpython-6afb285ff0790471a6858e44f85d143f07fda70c.zip cpython-6afb285ff0790471a6858e44f85d143f07fda70c.tar.gz cpython-6afb285ff0790471a6858e44f85d143f07fda70c.tar.bz2 |
bpo-45020: Add tests for the -X "frozen_modules" option. (gh-28997)
We hadn't explicitly added any tests for this, so here they are.
https://bugs.python.org/issue45020
Diffstat (limited to 'Lib/test/test_cmd_line.py')
-rw-r--r-- | Lib/test/test_cmd_line.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py index 1dc8c45..86ee274 100644 --- a/Lib/test/test_cmd_line.py +++ b/Lib/test/test_cmd_line.py @@ -123,6 +123,21 @@ class CmdLineTest(unittest.TestCase): else: self.assertEqual(err, b'') + def test_xoption_frozen_modules(self): + tests = { + ('=on', 'FrozenImporter'), + ('=off', 'SourceFileLoader'), + ('=', 'FrozenImporter'), + ('', 'FrozenImporter'), + } + for raw, expected in tests: + cmd = ['-X', f'frozen_modules{raw}', + #'-c', 'import os; print(os.__spec__.loader.__name__, end="")'] + '-c', 'import os; print(os.__spec__.loader, end="")'] + with self.subTest(raw): + res = assert_python_ok(*cmd) + self.assertRegex(res.out.decode('utf-8'), expected) + def test_run_module(self): # Test expected operation of the '-m' switch # Switch needs an argument |