|
6 | 6 | from importlib.metadata import ( |
7 | 7 | Distribution, |
8 | 8 | PackageNotFoundError, |
| 9 | + Prepared, |
9 | 10 | distribution, |
10 | 11 | entry_points, |
11 | 12 | files, |
@@ -313,3 +314,35 @@ class InvalidateCache(unittest.TestCase): |
313 | 314 | def test_invalidate_cache(self): |
314 | 315 | # No externally observable behavior, but ensures test coverage... |
315 | 316 | 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