Skip to content

Commit 4c61691

Browse files
authored
bpo-45506: Fix test_embed expecting to not find stdlib in source tree build when stdlib has been installed. (GH-29649)
1 parent 546cefc commit 4c61691

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

Lib/test/test_embed.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@
3535
MAX_HASH_SEED = 4294967295
3636

3737

38+
# If we are running from a build dir, but the stdlib has been installed,
39+
# some tests need to expect different results.
40+
STDLIB_INSTALL = os.path.join(sys.prefix, sys.platlibdir,
41+
f'python{sys.version_info.major}.{sys.version_info.minor}')
42+
if not os.path.isfile(os.path.join(STDLIB_INSTALL, 'os.py')):
43+
STDLIB_INSTALL = None
44+
3845
def debug_build(program):
3946
program = os.path.basename(program)
4047
name = os.path.splitext(program)[0]
@@ -1307,10 +1314,8 @@ def test_init_pybuilddir(self):
13071314
'base_executable': executable,
13081315
'executable': executable,
13091316
'module_search_paths': module_search_paths,
1310-
# The current getpath.c doesn't determine the stdlib dir
1311-
# in this case.
1312-
'stdlib_dir': None,
1313-
'use_frozen_modules': -1,
1317+
'stdlib_dir': STDLIB_INSTALL,
1318+
'use_frozen_modules': 1 if STDLIB_INSTALL else -1,
13141319
}
13151320
env = self.copy_paths_by_env(config)
13161321
self.check_all_configs("test_init_compat_config", config,
@@ -1381,8 +1386,8 @@ def test_init_pyvenv_cfg(self):
13811386
else:
13821387
# The current getpath.c doesn't determine the stdlib dir
13831388
# in this case.
1384-
config['stdlib_dir'] = None
1385-
config['use_frozen_modules'] = -1
1389+
config['stdlib_dir'] = STDLIB_INSTALL
1390+
config['use_frozen_modules'] = 1 if STDLIB_INSTALL else -1
13861391

13871392
env = self.copy_paths_by_env(config)
13881393
self.check_all_configs("test_init_compat_config", config,

0 commit comments

Comments
 (0)