[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 8704d6b391)

Co-authored-by: Miro Hrončok <miro@hroncok.cz>
This commit is contained in:
Miss Islington (bot) 2025-05-27 11:28:30 +02:00 committed by GitHub
parent 58549cfd49
commit 266b541cc6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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