Coverage for tests/test_main.py: 100%
20 statements
« prev ^ index » next coverage.py v7.14.1, created at 2026-10-30 22:54 +0000
« prev ^ index » next coverage.py v7.14.1, created at 2026-10-30 22:54 +0000
1"""Tests the `wonka` package metadata and namespace."""
3from __future__ import annotations
5import importlib.metadata
6import importlib.resources
8import wonka
11def test_version() -> None:
12 """Tests that the package and installed versions match."""
13 assert wonka.__version__ == '0.3.0'
14 assert importlib.metadata.version('wonka') == wonka.__version__
17def test_all_names_are_exported() -> None:
18 """Tests that every name in `__all__` exists in the package."""
19 assert 'AutoRegistrar' in wonka.__all__
20 assert 'Cluster' in wonka.__all__
21 for name in wonka.__all__:
22 assert hasattr(wonka, name)
25def test_all_is_sorted_and_unique() -> None:
26 """Tests that `__all__` has no duplicates and is sorted."""
27 assert len(set(wonka.__all__)) == len(wonka.__all__)
28 classes = [n for n in wonka.__all__ if n[0].isupper()]
29 functions = [n for n in wonka.__all__ if n[0].islower()]
30 assert classes == sorted(classes)
31 assert functions == sorted(functions)
34def test_package_is_typed() -> None:
35 """Tests that the package ships the `py.typed` marker."""
36 assert importlib.resources.files('wonka').joinpath('py.typed').is_file()
39if __name__ == '__main__':
40 test_version()