From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Tue, 27 May 2025 09:28:30 +0000 (+0200) Subject: [3.14] gh-62824: Adjust test_alias_modules_exist test to use imports instead of file... X-Git-Tag: v3.14.0b3~161 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=266b541cc6f231d9e04fa2084d5c67acd9c7b572;p=thirdparty%2FPython%2Fcpython.git [3.14] gh-62824: Adjust test_alias_modules_exist test to use imports instead of file checks (GH-134777) (GH-134781) gh-62824: Adjust test_alias_modules_exist test to use imports instead of file checks (GH-134777) (cherry picked from commit 8704d6b39139d2b1c3dd871590188fb7deb8aaad) Co-authored-by: Miro HronĨok --- diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py index 8c9a09724922..d8666f7290e7 100644 --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -1,6 +1,7 @@ import codecs import contextlib import copy +import importlib import io import pickle import os @@ -3111,9 +3112,9 @@ class TransformCodecTest(unittest.TestCase): def test_alias_modules_exist(self): encodings_dir = os.path.dirname(encodings.__file__) for value in encodings.aliases.aliases.values(): - codec_file = os.path.join(encodings_dir, value + ".py") - self.assertTrue(os.path.isfile(codec_file), - "Codec file not found: " + codec_file) + codec_mod = f"encodings.{value}" + self.assertIsNotNone(importlib.util.find_spec(codec_mod), + f"Codec module not found: {codec_mod}") def test_quopri_stateless(self): # Should encode with quotetabs=True