mirror of
https://github.com/python/cpython.git
synced 2025-08-24 10:45:53 +00:00
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
This commit is contained in:
parent
2b8677a3cd
commit
6afb285ff0
3 changed files with 78 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue