[docutils:bugs] #500 Html5WriterPublishPartsTestCase.test_publish skips too much when with_pygments is False
Günter Milde via Docutils-develop <[email protected]> Tue, 20 May 2025 11:53:52 -0000
| Newsgroups | gmane.text.docutils.devel |
|---|---|
| Message-ID | </p/docutils/bugs/500/3c9b4fa4e115645870d415424b7ac478f75b964e.bugs@docutils.p.sourceforge.net> |
- **status**: open-fixed --> open
- **Comment**:
PIL error outputs seem to be hard to predict. I got absolute paths with
Python 3.9.2 / Pillow 9.1.1 and Python 3.11.2 / Pillow 9.4.0.
It also depends on whether `Image.open()` is passed a `str` or a `Path`.
Could you try the following patch? (It works here with the versions above.)
~~~
diff --git a/docutils/test/test_writers/test_html5_polyglot.py b/docutils/test/test_writers/test_html5_polyglot.py
index f31277a36..b2fc3cc23 100644
--- a/docutils/test/test_writers/test_html5_polyglot.py
+++ b/docutils/test/test_writers/test_html5_polyglot.py
@@ -41,13 +41,11 @@
if PIL:
REQUIRES_PIL = ''
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])
- # 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())
+ # Pillow versions vary in their error output (cf. bugs: #485 and #500)
+ try:
+ PIL.Image.open(Path('dummy.png'))
+ except OSError as err:
+ DUMMY_PNG_NOT_FOUND = str(err)
HEIGHT_ATTR = 'height="32" '
WIDTH_ATTR = 'width="32" '
NO_PIL_SYSTEM_MESSAGE = ''
@@ -90,7 +88,7 @@ def test_publish(self):
**settings_overrides,
}
)
- self.assertEqual(case_expected, parts['body'])
+ self.assertEqual(case_expected, parts[ 'body'])
totest = {} # expected samples contain only the "body" part of the HMTL output
~~~
---
**[bugs:#500] Html5WriterPublishPartsTestCase.test_publish skips too much when with_pygments is False**
**Status:** open
**Created:** Mon May 19, 2025 10:15 AM UTC by Michał Górny
**Last Updated:** Tue May 20, 2025 12:52 AM UTC
**Owner:** nobody
While debugging something else, I've noticed that the `Html5WriterPublishPartsTestCase.test_publish()` case contains the following bit:
```
for name, (settings_overrides, cases) in totest.items():
if name == 'syntax_highlight' and not with_pygments:
self.skipTest('syntax highlight requires pygments')
```
This means that if `with_pygments` is `False`, all the remaining cases from `totest` are skipped. If I replace it with:
```
for name, (settings_overrides, cases) in totest.items():
if name == 'syntax_highlight' and not with_pygments:
continue
```
I see some test regressions too.
---
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.