[docutils:bugs] #484 0.21.1: `test_writers.test_html5_polyglot_parts.Html5WriterPublishPartsTestCase` test failures

Günter Milde via Docutils-develop <[email protected]>
Newsgroups gmane.text.docutils.devel
Message-ID </p/docutils/bugs/484/8cf5bfb8107cef94bb7cc51323bdb2379a7a7e8a.bugs@docutils.p.sourceforge.net>
Thank you for the report.
The reason seems to be that pygments output changed in version 2.14
Could you try the following patch?
~~~ diff
diff --git a/docutils/test/test_writers/test_html5_polyglot_parts.py b/docutils/test/test_writers/test_html5_polyglot_parts.py
index fb2792ee7..5b17492ad 100644
--- a/docutils/test/test_writers/test_html5_polyglot_parts.py
+++ b/docutils/test/test_writers/test_html5_polyglot_parts.py
@@ -14,6 +14,7 @@
 
 from pathlib import Path
 import os
+import re
 import sys
 import unittest
 
@@ -25,6 +26,12 @@
 import docutils
 import docutils.core
 from docutils.utils.code_analyzer import with_pygments
+if with_pygments:
+    import pygments
+    _pv = re.match(r'^([0-9]+)\.([0-9]*)', pygments.__version__)
+    if (int(_pv[1]), int(_pv[2])) >= (2, 14):  
+        # pygments output changed in version 2.14
+        with_pygments = False        
 
 ROOT_PREFIX = (Path(__file__).parent.parent/'functional'/'input').as_posix()
 DATA_ROOT = os.path.abspath(os.path.join(__file__, '..', '..', 'data'))
~~~


---

**[bugs:#484] 0.21.1: `test_writers.test_html5_polyglot_parts.Html5WriterPublishPartsTestCase` test failures**

**Status:** open
**Created:** Thu Apr 11, 2024 02:44 PM UTC by Michał Górny
**Last Updated:** Thu Apr 11, 2024 02:44 PM UTC
**Owner:** nobody


0.21.1 introduced three test regressions. The two of them are specific to `test_writers.test_html5_polyglot_parts.Html5WriterPublishPartsTestCase`. The errors are:

```
$ python3.10 alltests.py 
Testing Docutils 0.21.1 with Python 3.10.14 on 2024-04-11 at 16:42:02
OS: Linux 6.8.4-gentoo-dist #1 SMP PREEMPT_DYNAMIC Fri Apr  5 12:29:35 -00 2024 (linux, Linux-6.8.4-gentoo-dist-x86_64-AMD_Ryzen_5_3600_6-Core_Processor-with-glibc2.39)
Working directory: /tmp/docutils/test
Docutils package: /tmp/docutils/docutils
.....................................................................s.................................................................................................................................................................................................................s.....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s..........................................................................................................EEE...........................................................................................
======================================================================
FAIL: test_publish (test_writers.test_html5_polyglot_parts.Html5WriterPublishPartsTestCase) (id="totest['syntax_highlight'][0]")
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/docutils/test/test_writers/test_html5_polyglot_parts.py", line 56, in test_publish
    self.assertEqual(case_expected, self.format_output(parts))
AssertionError: {'fra[51 chars]e>cat <span class="s"><<EOF\nHello World[24 chars]>\n'} != {'fra[51 chars]e>cat<span class="w"> </span><span class="s">&[47 chars]>\n'}
- {'fragment': '<pre class="code shell literal-block"><code>cat <span '
?                                                              -

+ {'fragment': '<pre class="code shell literal-block"><code>cat<span class="w"> '
?                                                                    +++++++++++

-              'class="s"><<EOF\n'
+              '</span><span class="s"><<EOF\n'
?               +++++++++++++

               'Hello World\n'
               'EOF</span></code></pre>\n'}

======================================================================
FAIL: test_publish (test_writers.test_html5_polyglot_parts.Html5WriterPublishPartsTestCase) (id="totest['syntax_highlight'][1]")
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/docutils/test/test_writers/test_html5_polyglot_parts.py", line 56, in test_publish
    self.assertEqual(case_expected, self.format_output(parts))
AssertionError: {'fra[30 chars]">cat <span class="s"><<EOF Hello World [20 chars]>\n'} != {'fra[30 chars]">cat<span class="w"> </span><span class="s">&[43 chars]>\n'}
- {'fragment': '<p><code class="shell">cat <span class="s"><<EOF Hello '
?                                         -             ^  ^^^^^^^^^^^^^^^^^

+ {'fragment': '<p><code class="shell">cat<span class="w"> </span><span '
?                                                      ^  ^^^^^^^^^^^^^

-              'World EOF</span></code></p>\n'}
+              'class="s"><<EOF Hello World EOF</span></code></p>\n'}
?               ++++++++++++++++++++++++++++


```

Bisected it down to:

```
commit c6abd4cdee5323630fd7ac12b425bfc3f6d23075
Author: milde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>
Date:   Fri Nov 10 13:12:16 2023 +0000

    Simplify "HTML5 parts test", add test case for bug #476.
    
    git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@9470 929543f6-e4f2-0310-98a6-ba3bd3dd1d04

 test/test_writers/test_html5_polyglot_parts.py | 286 ++++---------------------
 1 file changed, 47 insertions(+), 239 deletions(-)
```

I can reproduce with Python 3.10.14, 3.11.9, 3.12.3; Pillow 10.3.0, Pygments 2.17.2.


---

Sent from sourceforge.net because [email protected] is subscribed to https://sourceforge.net/p/docutils/bugs/

To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/docutils/admin/bugs/options.  Or, if this is a mailing list, you can unsubscribe from the mailing list.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.