mirror of
https://github.com/python/cpython.git
synced 2025-07-19 01:05:26 +00:00
bpo-45020: Add more test cases for frozen modules. (gh-28664)
I've added a number of test-only modules. Some of those cases are covered by the recently frozen stdlib modules (and some will be once we add encodings back in). However, I figured we'd play it safe by having a set of modules guaranteed to be there during tests. https://bugs.python.org/issue45020
This commit is contained in:
parent
ec4d917a6a
commit
7e5c107541
13 changed files with 204 additions and 23 deletions
|
@ -19,6 +19,7 @@ from update_file import updating_file_with_tmpfile, update_file_with_tmpfile
|
|||
|
||||
ROOT_DIR = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
|
||||
ROOT_DIR = os.path.abspath(ROOT_DIR)
|
||||
FROZEN_ONLY = os.path.join(ROOT_DIR, 'Tools', 'freeze', 'flag.py')
|
||||
|
||||
STDLIB_DIR = os.path.join(ROOT_DIR, 'Lib')
|
||||
# If MODULES_DIR is changed then the .gitattributes and .gitignore files
|
||||
|
@ -53,7 +54,6 @@ FROZEN_FILE = os.path.join(ROOT_DIR, 'Python', 'frozen.c')
|
|||
MAKEFILE = os.path.join(ROOT_DIR, 'Makefile.pre.in')
|
||||
PCBUILD_PROJECT = os.path.join(ROOT_DIR, 'PCbuild', '_freeze_module.vcxproj')
|
||||
PCBUILD_FILTERS = os.path.join(ROOT_DIR, 'PCbuild', '_freeze_module.vcxproj.filters')
|
||||
TEST_CTYPES = os.path.join(STDLIB_DIR, 'ctypes', 'test', 'test_values.py')
|
||||
|
||||
|
||||
OS_PATH = 'ntpath' if os.name == 'nt' else 'posixpath'
|
||||
|
@ -95,8 +95,11 @@ FROZEN = [
|
|||
]),
|
||||
('Test module', [
|
||||
'__hello__',
|
||||
'__hello__ : <__phello__>',
|
||||
'__hello__ : __phello__.spam',
|
||||
'__hello__ : __hello_alias__',
|
||||
'__hello__ : <__phello_alias__>',
|
||||
'__hello__ : __phello_alias__.spam',
|
||||
'<__phello__.**.*>',
|
||||
f'frozen_only : __hello_only__ = {FROZEN_ONLY}',
|
||||
]),
|
||||
]
|
||||
ESSENTIAL = {
|
||||
|
@ -135,14 +138,15 @@ def parse_frozen_specs(sectionalspecs=FROZEN, destdir=None):
|
|||
seen = {}
|
||||
for section, specs in sectionalspecs:
|
||||
parsed = _parse_specs(specs, section, seen)
|
||||
for frozenid, pyfile, modname, ispkg, section in parsed:
|
||||
for item in parsed:
|
||||
frozenid, pyfile, modname, ispkg, section = item
|
||||
try:
|
||||
source = seen[frozenid]
|
||||
except KeyError:
|
||||
source = FrozenSource.from_id(frozenid, pyfile, destdir)
|
||||
seen[frozenid] = source
|
||||
else:
|
||||
assert not pyfile
|
||||
assert not pyfile or pyfile == source.pyfile, item
|
||||
yield FrozenModule(modname, ispkg, section, source)
|
||||
|
||||
|
||||
|
@ -224,7 +228,6 @@ def _parse_spec(spec, knownids=None, section=None):
|
|||
pkgfiles = {pyfile: pkgid}
|
||||
def iter_subs():
|
||||
for frozenid, pyfile, ispkg in resolved:
|
||||
assert not knownids or frozenid not in knownids, (frozenid, spec)
|
||||
if pkgname:
|
||||
modname = frozenid.replace(pkgid, pkgname, 1)
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue