|
6 | 6 | from importlib_metadata import ( |
7 | 7 | Distribution, |
8 | 8 | PackageNotFoundError, |
| 9 | + Prepared, |
9 | 10 | distribution, |
10 | 11 | entry_points, |
11 | 12 | files, |
@@ -317,3 +318,34 @@ class InvalidateCache(unittest.TestCase): |
317 | 318 | def test_invalidate_cache(self): |
318 | 319 | # No externally observable behavior, but ensures test coverage... |
319 | 320 | importlib.invalidate_caches() |
| 321 | + |
| 322 | + |
| 323 | +class PreparedTests(unittest.TestCase): |
| 324 | + @fixtures.parameterize( |
| 325 | + # Simple |
| 326 | + dict(input='sample', expected='sample'), |
| 327 | + # Mixed case |
| 328 | + dict(input='Sample', expected='sample'), |
| 329 | + dict(input='SAMPLE', expected='sample'), |
| 330 | + dict(input='SaMpLe', expected='sample'), |
| 331 | + # Separator conversions |
| 332 | + dict(input='sample-pkg', expected='sample_pkg'), |
| 333 | + dict(input='sample.pkg', expected='sample_pkg'), |
| 334 | + dict(input='sample_pkg', expected='sample_pkg'), |
| 335 | + # Multiple separators |
| 336 | + dict(input='sample---pkg', expected='sample_pkg'), |
| 337 | + dict(input='sample___pkg', expected='sample_pkg'), |
| 338 | + dict(input='sample...pkg', expected='sample_pkg'), |
| 339 | + # Mixed separators |
| 340 | + dict(input='sample-._pkg', expected='sample_pkg'), |
| 341 | + dict(input='sample_.-pkg', expected='sample_pkg'), |
| 342 | + # Complex |
| 343 | + dict(input='Sample__Pkg-name.foo', expected='sample_pkg_name_foo'), |
| 344 | + dict(input='Sample__Pkg.name__foo', expected='sample_pkg_name_foo'), |
| 345 | + # Uppercase with separators |
| 346 | + dict(input='SAMPLE-PKG', expected='sample_pkg'), |
| 347 | + dict(input='Sample.Pkg', expected='sample_pkg'), |
| 348 | + dict(input='SAMPLE_PKG', expected='sample_pkg'), |
| 349 | + ) |
| 350 | + def test_normalize(self, input, expected): |
| 351 | + self.assertEqual(Prepared.normalize(input), expected) |
0 commit comments