File: test_pygments.py

package info (click to toggle)
ipython 8.35.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,696 kB
  • sloc: python: 42,461; sh: 376; makefile: 243
file content (26 lines) | stat: -rw-r--r-- 824 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from typing import List

import pytest
import pygments.lexers
import pygments.lexer

from IPython.lib.lexers import IPythonConsoleLexer, IPythonLexer, IPython3Lexer

#: the human-readable names of the IPython lexers with ``entry_points``
EXPECTED_LEXER_NAMES = [
    cls.name for cls in [IPythonConsoleLexer, IPythonLexer, IPython3Lexer]
]


@pytest.fixture
def all_pygments_lexer_names() -> List[str]:
    """Get all lexer names registered in pygments."""
    return {l[0] for l in pygments.lexers.get_all_lexers()}


@pytest.mark.parametrize("expected_lexer", EXPECTED_LEXER_NAMES)
def test_pygments_entry_points(
    expected_lexer: str, all_pygments_lexer_names: List[str]
) -> None:
    """Check whether the ``entry_points`` for ``pygments.lexers`` are correct."""
    assert expected_lexer in all_pygments_lexer_names