relax tests for old pygments

This commit is contained in:
Will McGugan 2023-03-04 15:14:15 +00:00
parent e897cd3909
commit 42e1ec9157
2 changed files with 7 additions and 1 deletions

View File

@ -28,7 +28,7 @@ include = ["rich/py.typed"]
[tool.poetry.dependencies] [tool.poetry.dependencies]
python = ">=3.7.0" python = ">=3.7.0"
typing-extensions = { version = ">=4.0.0, <5.0", python = "<3.9" } typing-extensions = { version = ">=4.0.0, <5.0", python = "<3.9" }
pygments = "^2.14.0" pygments = "^2.13.0"
ipywidgets = { version = ">=7.5.1,<9", optional = true } ipywidgets = { version = ">=7.5.1,<9", optional = true }
markdown-it-py = "^2.2.0" markdown-it-py = "^2.2.0"

View File

@ -3,6 +3,7 @@ import os
import sys import sys
import tempfile import tempfile
import pkg_resources
import pytest import pytest
from pygments.lexers import PythonLexer from pygments.lexers import PythonLexer
@ -20,6 +21,9 @@ from rich.syntax import (
from .render import render from .render import render
PYGMENTS_VERSION = pkg_resources.get_distribution("pygments").version
OLD_PYGMENTS = PYGMENTS_VERSION == "2.13.0"
CODE = '''\ CODE = '''\
def loop_first_last(values: Iterable[T]) -> Iterable[Tuple[bool, bool, T]]: def loop_first_last(values: Iterable[T]) -> Iterable[Tuple[bool, bool, T]]:
"""Iterate and generate a tuple with a flag for first and last value.""" """Iterate and generate a tuple with a flag for first and last value."""
@ -98,6 +102,7 @@ def test_python_render_simple_passing_lexer_instance():
assert rendered_syntax == expected assert rendered_syntax == expected
@pytest.mark.skipif(OLD_PYGMENTS, reason="Pygments changed their tokenizer")
def test_python_render_simple_indent_guides(): def test_python_render_simple_indent_guides():
syntax = Syntax( syntax = Syntax(
CODE, CODE,
@ -114,6 +119,7 @@ def test_python_render_simple_indent_guides():
assert rendered_syntax == expected assert rendered_syntax == expected
@pytest.mark.skipif(OLD_PYGMENTS, reason="Pygments changed their tokenizer")
def test_python_render_line_range_indent_guides(): def test_python_render_line_range_indent_guides():
syntax = Syntax( syntax = Syntax(
CODE, CODE,