]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-89745: Avoid exact match when comparing program_name in test_embed on Windows...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 17 Jun 2022 10:31:03 +0000 (03:31 -0700)
committerGitHub <noreply@github.com>
Fri, 17 Jun 2022 10:31:03 +0000 (03:31 -0700)
(cherry picked from commit ffc228dd4e409336f2c2ad54125de384bf1a767b)

Co-authored-by: neonene <53406459+neonene@users.noreply.github.com>
Lib/test/test_embed.py

index 5ba6e3a43fdc6e98a60bc07da600b41032685dc2..c863805d0fefa9049ad5c49beebd058804345464 100644 (file)
@@ -630,7 +630,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
         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']
@@ -673,14 +673,6 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
             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():
@@ -710,6 +702,11 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
 
     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)
@@ -774,7 +771,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
         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)