[Python-checkins] gh-89745: Avoid exact match when comparing program_name in test_embed on Windows (GH-93888)
zooba
webhook-mailer at python.org
Fri Jun 17 06:06:57 EDT 2022
https://github.com/python/cpython/commit/ffc228dd4e409336f2c2ad54125de384bf1a767b
commit: ffc228dd4e409336f2c2ad54125de384bf1a767b
branch: main
author: neonene <53406459+neonene at users.noreply.github.com>
committer: zooba <steve.dower at microsoft.com>
date: 2022-06-17T11:06:49+01:00
summary:
gh-89745: Avoid exact match when comparing program_name in test_embed on Windows (GH-93888)
files:
M Lib/test/test_embed.py
diff --git a/Lib/test/test_embed.py b/Lib/test/test_embed.py
index 0229cf3c3127f..b2a1eba34b650 100644
--- a/Lib/test/test_embed.py
+++ b/Lib/test/test_embed.py
@@ -629,7 +629,7 @@ def _get_expected_config(self):
return configs
def get_expected_config(self, expected_preconfig, expected,
- env, api, modify_path_cb=None, cwd=None):
+ env, api, modify_path_cb=None):
configs = self._get_expected_config()
pre_config = configs['pre_config']
@@ -672,14 +672,6 @@ def get_expected_config(self, expected_preconfig, expected,
expected['base_executable'] = default_executable
if expected['program_name'] is self.GET_DEFAULT_CONFIG:
expected['program_name'] = './_testembed'
- if MS_WINDOWS:
- # follow the calculation in getpath.py
- tmpname = expected['program_name'] + '.exe'
- if cwd:
- tmpname = os.path.join(cwd, tmpname)
- if os.path.isfile(tmpname):
- expected['program_name'] += '.exe'
- del tmpname
config = configs['config']
for key, value in expected.items():
@@ -709,6 +701,11 @@ def check_pre_config(self, configs, expected):
def check_config(self, configs, expected):
config = dict(configs['config'])
+ if MS_WINDOWS:
+ value = config.get(key := 'program_name')
+ if value and isinstance(value, str):
+ ext = '_d.exe' if debug_build(sys.executable) else '.exe'
+ config[key] = value[:len(value.lower().removesuffix(ext))]
for key, value in list(expected.items()):
if value is self.IGNORE_CONFIG:
config.pop(key, None)
@@ -773,7 +770,7 @@ def check_all_configs(self, testname, expected_config=None,
self.get_expected_config(expected_preconfig,
expected_config,
env,
- api, modify_path_cb, cwd)
+ api, modify_path_cb)
out, err = self.run_embedded_interpreter(testname,
env=env, cwd=cwd)
More information about the Python-checkins
mailing list