|
From: Guenter M. <mi...@us...> - 2023-04-13 14:38:22
|
Dear Adam, On 2023-04-06, Adam Turner wrote: > Pygments 2.14, released in January__, contains changes__ in the Python > lexer which break ``test_code``, ``test_code_long``, and ``test_include``. > __ https://pygments.org/docs/changelog/#version-2-14-0 > __ https://github.com/pygments/pygments/commit/147b22face65617514ccfa8512c6b097b07cad4c > I have attached a sample patch to fix these and maintain support in the > tests for Pygments 2.13 and earlier. Thank you. Do you think this should go to 0.20? In the proposed patch, the Pygments version parsing fails for pre-release versions (for examples, c.f. https://pygments.org/docs/changelog/). The patch below demonstrates an alternative parsing that is a bit more robust. > A different approach would be to declare that the tests only support > the latest version of Pygments (it is currently unclear which version > of Pygments is our minimum supported). This would mean to skip the tests not only if Pygments is not installed at all but also for a non-matching version. Would be possible, but has the disadvantage of not testing versions that OTOH still work fine "in praxi". (And that developers with distribution-installed Pygments that is not bleeding edge may fail to find regressions in the syntax parsing.) I favour the "versioned" tests (keeping the old version until Pagments 2.14 is in Debian/stable). Thanks, Günter diff --git a/docutils/test/test_parsers/test_rst/test_directives/test_code.py b/docutils/test/test_parsers/test_rst/test_directives/test_code.py index 7985d1b65..6fab49644 100755 --- a/docutils/test/test_parsers/test_rst/test_directives/test_code.py +++ b/docutils/test/test_parsers/test_rst/test_directives/test_code.py @@ -9,6 +9,7 @@ """ from pathlib import Path +import re import sys import unittest @@ -23,12 +24,12 @@ from docutils.utils.code_analyzer import with_pygments try: - from pygments import __version__ as _pygments_ver + import pygments except ImportError: - _pygments_ver = '' - PYGMENTS_2_14_PLUS = False + PYGMENTS_2_14_PLUS = None else: - PYGMENTS_2_14_PLUS = tuple(map(int, _pygments_ver.split('.'))) >= (2, 14) + _pv = re.match(r'^([0-9]+)\.([0-9]*)', pygments.__version__) + PYGMENTS_2_14_PLUS = (int(_pv[1]), int(_pv[2])) >= (2, 14) class ParserTestCase(unittest.TestCase): |