SF.net SVN: docutils:[10134 ] trunk/docutils/test
milde--- via Docutils-checkins <[email protected]> Mon, 19 May 2025 21:12:35 +0000
| Newsgroups | gmane.text.docutils.cvs |
|---|---|
| Message-ID | <[email protected]> |
Revision: 10134
http://sourceforge.net/p/docutils/code/10134
Author: milde
Date: 2025-05-19 21:12:34 +0000 (Mon, 19 May 2025)
Log Message:
-----------
Fixes for the test suite.
Move skipTest-clauses in a loop into sub-tests to avoid aborting the loop.
Fixes [bugs:#500].
Fix false positives due to version-dependent error messages from PIL and
parsing output from pygments.
Fix typo.
Modified Paths:
--------------
trunk/docutils/test/test_nodes.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_code.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py
trunk/docutils/test/test_parsers/test_rst/test_interpreted.py
trunk/docutils/test/test_writers/test_html5_polyglot.py
Modified: trunk/docutils/test/test_nodes.py
===================================================================
--- trunk/docutils/test/test_nodes.py 2025-05-16 16:25:37 UTC (rev 10133)
+++ trunk/docutils/test/test_nodes.py 2025-05-19 21:12:34 UTC (rev 10134)
@@ -937,7 +937,7 @@
self.visitor.dispatch_visit(self.element)
def test_dispatch_visit_optional(self):
- # silently skip nodes of a calss in tuple nodes.NodeVisitor.optional
+ # silently skip nodes of a class in tuple nodes.NodeVisitor.optional
rv = self.visitor.dispatch_visit(nodes.meta())
self.assertIsNone(rv)
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-05-16 16:25:37 UTC (rev 10133)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_code.py 2025-05-19 21:12:34 UTC (rev 10134)
@@ -43,10 +43,10 @@
settings.warning_stream = ''
settings.report_level = 5
for name, cases in totest.items():
- if name == 'code_parsing' and not with_pygments:
- self.skipTest('syntax highlight requires pygments')
for casenum, (case_input, case_expected) in enumerate(cases):
with self.subTest(id=f'totest[{name!r}][{casenum}]'):
+ if name == 'code_parsing' and not with_pygments:
+ self.skipTest('syntax highlight requires pygments')
document = new_document('test data', settings.copy())
parser.parse(case_input, document)
output = document.pformat()
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py 2025-05-16 16:25:37 UTC (rev 10133)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py 2025-05-19 21:12:34 UTC (rev 10134)
@@ -47,13 +47,13 @@
for name, cases in totest.items():
if name == 'with transforms':
continue # see test_publish() below
- # eventually skip optional parts:
- if name == 'include_markdown' and not md_parser_class:
- self.skipTest('no markdown parser available')
- if name == 'include_parsed_code' and not with_pygments:
- self.skipTest('syntax highlight requires pygments')
for casenum, (case_input, case_expected) in enumerate(cases):
with self.subTest(id=f'totest[{name!r}][{casenum}]'):
+ # eventually skip optional parts:
+ if name == 'include_markdown' and not md_parser_class:
+ self.skipTest('no markdown parser available')
+ if name == 'include_parsed_code' and not with_pygments:
+ self.skipTest('syntax highlight requires pygments')
document = new_document('test data', settings.copy())
parser.parse(case_input, document)
output = document.pformat()
Modified: trunk/docutils/test/test_parsers/test_rst/test_interpreted.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_interpreted.py 2025-05-16 16:25:37 UTC (rev 10133)
+++ trunk/docutils/test/test_parsers/test_rst/test_interpreted.py 2025-05-19 21:12:34 UTC (rev 10134)
@@ -29,10 +29,10 @@
settings = get_default_settings(Parser)
settings.warning_stream = ''
for name, cases in totest.items():
- if name == 'code_parsing' and not with_pygments:
- self.skipTest('syntax highlight requires pygments')
for casenum, (case_input, case_expected) in enumerate(cases):
with self.subTest(id=f'totest[{name!r}][{casenum}]'):
+ if name == 'code_parsing' and not with_pygments:
+ self.skipTest('syntax highlight requires pygments')
document = new_document('test data', settings.copy())
parser.parse(case_input, document)
output = document.pformat()
Modified: trunk/docutils/test/test_writers/test_html5_polyglot.py
===================================================================
--- trunk/docutils/test/test_writers/test_html5_polyglot.py 2025-05-16 16:25:37 UTC (rev 10133)
+++ trunk/docutils/test/test_writers/test_html5_polyglot.py 2025-05-19 21:12:34 UTC (rev 10134)
@@ -28,7 +28,7 @@
if with_pygments:
import pygments
- if tuple(map(int, pygments.__version__.split('.')[:2])) >= (2, 14):
+ if tuple(map(int, pygments.__version__.split('.')[:2])) < (2, 14):
# pygments output changed in version 2.14
with_pygments = False
@@ -40,10 +40,12 @@
# Pillow/PIL is optional:
if PIL:
REQUIRES_PIL = ''
- ONLY_LOCAL = 'Can only read local images.'
+ ONLY_LOCAL = 'Cannot get file path corresponding to https://dummy.png.'
DUMMY_PNG_NOT_FOUND = "[Errno 2] No such file or directory: 'dummy.png'"
# Pillow reports the absolute path since version 10.3.0 (cf. [bugs: 485])
- if (tuple(int(i) for i in PIL.__version__.split('.')) >= (10, 3)):
+ # Backported to version 9.1 (or does it depend on the Python version)?
+ pil_version = tuple(int(i) for i in PIL.__version__.split('.'))
+ if pil_version >= (10, 3) or pil_version[0] == 9 and pil_version[1] >= 1:
DUMMY_PNG_NOT_FOUND = ("[Errno 2] No such file or directory: '%s'"
% Path('dummy.png').resolve())
HEIGHT_ATTR = 'height="32" '
@@ -73,10 +75,10 @@
def test_publish(self):
for name, (settings_overrides, cases) in totest.items():
- if name == 'syntax_highlight' and not with_pygments:
- self.skipTest('syntax highlight requires pygments')
for casenum, (case_input, case_expected) in enumerate(cases):
with self.subTest(id=f'totest[{name!r}][{casenum}]'):
+ if name == 'syntax_highlight' and not with_pygments:
+ self.skipTest('syntax highlight requires pygments')
parts = docutils.core.publish_parts(
source=case_input,
writer=html5_polyglot.Writer(),
@@ -519,7 +521,7 @@
EOF
""",
"""\
-<pre class="code shell literal-block"><code>cat <span class="s"><<EOF
+<pre class="code shell literal-block"><code>cat<span class="w"> </span><span class="s"><<EOF
Hello World
EOF</span></code></pre>
""",
@@ -531,7 +533,7 @@
:shell:`cat <<EOF Hello World EOF`
""",
"""\
-<p><code class="shell">cat <span class="s"><<EOF Hello World EOF</span></code></p>
+<p><code class="shell">cat<span class="w"> </span><span class="s"><<EOF Hello World EOF</span></code></p>
""",
],
])
@@ -550,7 +552,7 @@
<p class="system-message-title">System Message: ERROR/3 \
(<span class="docutils literal"><string></span>, line 1)</p>
<p>Cannot embed image "https://dummy.png":
- Can only read local images.</p>
+ Cannot get file path corresponding to https://dummy.png.</p>
</aside>
""",
],
@@ -642,7 +644,7 @@
<p class="system-message-title">System Message: ERROR/3 \
(<span class="docutils literal"><string></span>, line 1)</p>
<p>Cannot embed image "https://dummy.png":
- Can only read local images.</p>
+ Cannot get file path corresponding to https://dummy.png.</p>
</aside>
""",
],
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.