Debian Codegraph @

tests/test_main_entry_points.py

raw
1 """Regression tests for the console/gui-script entry points in pyproject.toml.
2
3 See issue #797: several entry points pointed at DisplayCAL.main:main_*
4 functions that did not exist, so the installed console scripts raised
5 AttributeError/ModuleNotFoundError on launch.
6 """
7
8 from importlib.metadata import entry_points
9
10 import pytest
11
12
13 def _displaycal_entry_points():
14 eps = entry_points()
15 for group in ("console_scripts", "gui_scripts"):
16 for ep in eps.select(group=group):
17 if ep.name.startswith("displaycal"):
18 yield ep
19
20
21 @pytest.mark.parametrize(
22 "ep", list(_displaycal_entry_points()), ids=lambda ep: ep.name
23 )
24 def test_entry_point_resolves_to_callable(ep):
25 """Every declared displaycal-* entry point must load to a callable."""
26 target = ep.load()
27
28 assert callable(target), f"{ep.name} ({ep.value}) did not resolve to a callable"
29
30
31 def test_at_least_one_entry_point_was_checked():
32 """Guard against the parametrization silently collecting zero entries."""
33 assert list(_displaycal_entry_points())