Skip to content

Commit e6cca2e

Browse files
gh-89745: Avoid exact match when comparing program_name in test_embed on Windows (GH-93888)
(cherry picked from commit ffc228d) Co-authored-by: neonene <53406459+neonene@users.noreply.github.com>
1 parent 123e3be commit e6cca2e

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

Lib/test/test_embed.py

+7-10
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ def _get_expected_config(self):
630630
return configs
631631

632632
def get_expected_config(self, expected_preconfig, expected,
633-
env, api, modify_path_cb=None, cwd=None):
633+
env, api, modify_path_cb=None):
634634
configs = self._get_expected_config()
635635

636636
pre_config = configs['pre_config']
@@ -673,14 +673,6 @@ def get_expected_config(self, expected_preconfig, expected,
673673
expected['base_executable'] = default_executable
674674
if expected['program_name'] is self.GET_DEFAULT_CONFIG:
675675
expected['program_name'] = './_testembed'
676-
if MS_WINDOWS:
677-
# follow the calculation in getpath.py
678-
tmpname = expected['program_name'] + '.exe'
679-
if cwd:
680-
tmpname = os.path.join(cwd, tmpname)
681-
if os.path.isfile(tmpname):
682-
expected['program_name'] += '.exe'
683-
del tmpname
684676

685677
config = configs['config']
686678
for key, value in expected.items():
@@ -710,6 +702,11 @@ def check_pre_config(self, configs, expected):
710702

711703
def check_config(self, configs, expected):
712704
config = dict(configs['config'])
705+
if MS_WINDOWS:
706+
value = config.get(key := 'program_name')
707+
if value and isinstance(value, str):
708+
ext = '_d.exe' if debug_build(sys.executable) else '.exe'
709+
config[key] = value[:len(value.lower().removesuffix(ext))]
713710
for key, value in list(expected.items()):
714711
if value is self.IGNORE_CONFIG:
715712
config.pop(key, None)
@@ -774,7 +771,7 @@ def check_all_configs(self, testname, expected_config=None,
774771
self.get_expected_config(expected_preconfig,
775772
expected_config,
776773
env,
777-
api, modify_path_cb, cwd)
774+
api, modify_path_cb)
778775

779776
out, err = self.run_embedded_interpreter(testname,
780777
env=env, cwd=cwd)

0 commit comments

Comments
 (0)