Skip to content

Commit 21c1e40

Browse files
committed
Look for modules in test_alias_modules_exist, not files
1 parent 46c025d commit 21c1e40

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

Lib/test/test_codecs.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import codecs
22
import contextlib
33
import copy
4+
import importlib
45
import io
56
import pickle
67
import os
@@ -3111,11 +3112,9 @@ def test_aliases(self):
31113112
def test_alias_modules_exist(self):
31123113
encodings_dir = os.path.dirname(encodings.__file__)
31133114
for value in encodings.aliases.aliases.values():
3114-
codec_file = os.path.join(encodings_dir, value + ".py")
3115-
pyc_file = codec_file + "c"
3116-
self.assertTrue(os.path.isfile(codec_file)
3117-
or os.path.isfile(pyc_file),
3118-
"Codec file not found: " + codec_file)
3115+
codec_mod = f"encodings.{value}"
3116+
self.assertIsNotNone(importlib.util.find_spec(codec_mod),
3117+
"Codec module not found: " + codec_mod)
31193118

31203119
def test_quopri_stateless(self):
31213120
# Should encode with quotetabs=True

0 commit comments

Comments
 (0)