Skip to content

Commit 1657880

Browse files
committed
Add tests for Prepared.normalize
1 parent 0eae552 commit 1657880

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

Lib/test/test_importlib/metadata/test_api.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from importlib.metadata import (
77
Distribution,
88
PackageNotFoundError,
9+
Prepared,
910
distribution,
1011
entry_points,
1112
files,
@@ -313,3 +314,35 @@ class InvalidateCache(unittest.TestCase):
313314
def test_invalidate_cache(self):
314315
# No externally observable behavior, but ensures test coverage...
315316
importlib.invalidate_caches()
317+
318+
319+
class PreparedTests(unittest.TestCase):
320+
def test_normalize(self):
321+
tests = [
322+
# Simple
323+
("sample", "sample"),
324+
# Mixed case
325+
("Sample", "sample"),
326+
("SAMPLE", "sample"),
327+
("SaMpLe", "sample"),
328+
# Separator conversions
329+
("sample-pkg", "sample_pkg"),
330+
("sample.pkg", "sample_pkg"),
331+
("sample_pkg", "sample_pkg"),
332+
# Multiple separators
333+
("sample---pkg", "sample_pkg"),
334+
("sample___pkg", "sample_pkg"),
335+
("sample...pkg", "sample_pkg"),
336+
# Mixed separators
337+
("sample-._pkg", "sample_pkg"),
338+
("sample_.-pkg", "sample_pkg"),
339+
# Complex
340+
("Sample__Pkg-name.foo", "sample_pkg_name_foo"),
341+
# Uppercase with separators
342+
("SAMPLE-PKG", "sample_pkg"),
343+
("Sample.Pkg", "sample_pkg"),
344+
("SAMPLE_PKG", "sample_pkg"),
345+
]
346+
for name, expected in tests:
347+
with self.subTest(name=name):
348+
self.assertEqual(Prepared.normalize(name), expected)

0 commit comments

Comments
 (0)