@@ -160,13 +160,7 @@ def test_command_help_exposes_only_relevant_options(
160160
161161
162162def test_pygments_style_entry_points_load () -> None :
163- if sys .version_info >= (3 , 11 ):
164- import tomllib
165- else :
166- tomllib = pytest .importorskip ("tomli" )
167-
168- pyproject = Path (__file__ ).parents [2 ] / "pyproject.toml"
169- project_config = tomllib .loads (pyproject .read_text (encoding = "utf-8" ))
163+ project_config = _load_pyproject_config ()
170164 entry_points = project_config ["project" ]["entry-points" ]["pygments.styles" ]
171165
172166 for entry_point in entry_points .values ():
@@ -176,6 +170,28 @@ def test_pygments_style_entry_points_load() -> None:
176170 assert getattr (module , attribute_name ) is not None
177171
178172
173+ def test_pygments_lexer_entry_points_load () -> None :
174+ project_config = _load_pyproject_config ()
175+ entry_points = project_config ["project" ]["entry-points" ]["pygments.lexers" ]
176+
177+ for entry_point in entry_points .values ():
178+ module_name , attribute_name = entry_point .split (":" , maxsplit = 1 )
179+ module = import_module (module_name )
180+
181+ assert getattr (module , attribute_name ) is not None
182+
183+
184+ def _load_pyproject_config () -> dict [str , object ]:
185+ toml = (
186+ import_module ("tomllib" )
187+ if sys .version_info >= (3 , 11 )
188+ else pytest .importorskip ("tomli" )
189+ )
190+
191+ pyproject = Path (__file__ ).parents [2 ] / "pyproject.toml"
192+ return toml .loads (pyproject .read_text (encoding = "utf-8" ))
193+
194+
179195def test_pdf_command_builds_pdf_config_and_calls_pdf_builder (
180196 runner : CliRunner ,
181197 monkeypatch : pytest .MonkeyPatch ,
0 commit comments