SF.net SVN: docutils:[10019] trunk/docutils/test
aa-turner--- via Docutils-checkins <[email protected]> Fri, 07 Mar 2025 22:49:47 +0000
| Newsgroups | gmane.text.docutils.cvs |
|---|---|
| Message-ID | <[email protected]> |
Revision: 10019
http://sourceforge.net/p/docutils/code/10019
Author: aa-turner
Date: 2025-03-07 22:49:46 +0000 (Fri, 07 Mar 2025)
Log Message:
-----------
Support Pygments 2.19 in tests
Modified Paths:
--------------
trunk/docutils/test/test_parsers/test_rst/test_directives/test_code.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_code_long.py
trunk/docutils/test/test_writers/test_html4css1.py
trunk/docutils/test/test_writers/test_html5_polyglot.py
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_code.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_code.py 2025-03-06 16:19:15 UTC (rev 10018)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_code.py 2025-03-07 22:49:46 UTC (rev 10019)
@@ -25,12 +25,18 @@
if with_pygments:
import pygments
- _pv = re.match(r'^([0-9]+)\.([0-9]*)', pygments.__version__)
- PYGMENTS_2_14_PLUS = (int(_pv[1]), int(_pv[2])) >= (2, 14)
+
+ pygments_version = tuple(map(int, pygments.__version__.split('.')[:2]))
else:
- PYGMENTS_2_14_PLUS = None
+ pygments_version = (0, 0)
+PYGMENTS_2_14_PLUS = pygments_version >= (2, 14)
+if pygments_version >= (2, 19):
+ def_ws = '<inline classes="whitespace">\n '
+else:
+ def_ws = ' '
+
class ParserTestCase(unittest.TestCase):
def test_parser(self):
parser = Parser()
@@ -159,7 +165,7 @@
# and now for something completely different
print(8/2)
""",
-"""\
+f"""\
<document source="test data">
<literal_block classes="code python3 testclass" ids="my-function" names="my_function" xml:space="preserve">
<inline classes="ln">
@@ -166,7 +172,7 @@
7 \n\
<inline classes="keyword">
def
- \n\
+ {def_ws}
<inline classes="name function">
my_function
<inline classes="punctuation">
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_code_long.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_code_long.py 2025-03-06 16:19:15 UTC (rev 10018)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_code_long.py 2025-03-07 22:49:46 UTC (rev 10019)
@@ -22,9 +22,8 @@
from docutils.utils import new_document
from docutils.utils.code_analyzer import with_pygments
from test.test_parsers.test_rst.test_directives.test_code \
- import PYGMENTS_2_14_PLUS
+ import PYGMENTS_2_14_PLUS, def_ws
-
@unittest.skipUnless(with_pygments, 'needs Pygments')
class ParserTestCase(unittest.TestCase):
def test_parser(self):
@@ -55,7 +54,7 @@
# and now for something completely different
print(8/2)
""",
-"""\
+f"""\
<document source="test data">
<literal_block classes="code python3" xml:space="preserve">
<inline classes="ln">
@@ -62,7 +61,7 @@
7 \n\
<inline classes="keyword">
def
- \n\
+ {def_ws}
<inline classes="name function">
my_function
<inline classes="punctuation">
Modified: trunk/docutils/test/test_writers/test_html4css1.py
===================================================================
--- trunk/docutils/test/test_writers/test_html4css1.py 2025-03-06 16:19:15 UTC (rev 10018)
+++ trunk/docutils/test/test_writers/test_html4css1.py 2025-03-07 22:49:46 UTC (rev 10019)
@@ -10,7 +10,6 @@
"""
from pathlib import Path
-import re
import sys
import unittest
@@ -27,8 +26,7 @@
if with_pygments:
import pygments
- _pv = re.match(r'^([0-9]+)\.([0-9]*)', pygments.__version__)
- if (int(_pv[1]), int(_pv[2])) >= (2, 14):
+ if tuple(map(int, pygments.__version__.split('.')[:2])) >= (2, 14):
# pygments output changed in version 2.14
with_pygments = False
Modified: trunk/docutils/test/test_writers/test_html5_polyglot.py
===================================================================
--- trunk/docutils/test/test_writers/test_html5_polyglot.py 2025-03-06 16:19:15 UTC (rev 10018)
+++ trunk/docutils/test/test_writers/test_html5_polyglot.py 2025-03-07 22:49:46 UTC (rev 10019)
@@ -11,7 +11,6 @@
"""
from pathlib import Path
-import re
import sys
import unittest
@@ -28,8 +27,7 @@
if with_pygments:
import pygments
- _pv = re.match(r'^([0-9]+)\.([0-9]*)', pygments.__version__)
- if (int(_pv[1]), int(_pv[2])) >= (2, 14):
+ if tuple(map(int, pygments.__version__.split('.')[:2])) >= (2, 14):
# pygments output changed in version 2.14
with_pygments = False
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.