SF.net SVN: docutils:[9958 ] trunk/docutils/test/test _writers/test_manpage.py

grubert--- via Docutils-checkins <[email protected]>
Newsgroups gmane.text.docutils.cvs
Message-ID <[email protected]>
Revision: 9958
          http://sourceforge.net/p/docutils/code/9958
Author:   grubert
Date:     2024-10-21 19:25:32 +0000 (Mon, 21 Oct 2024)
Log Message:
-----------
test manpage warning on image content

Modified Paths:
--------------
    trunk/docutils/test/test_writers/test_manpage.py

Modified: trunk/docutils/test/test_writers/test_manpage.py
===================================================================
--- trunk/docutils/test/test_writers/test_manpage.py	2024-10-21 07:20:00 UTC (rev 9957)
+++ trunk/docutils/test/test_writers/test_manpage.py	2024-10-21 19:25:32 UTC (rev 9958)
@@ -10,6 +10,8 @@
 from pathlib import Path
 import sys
 import unittest
+from io import StringIO
+import docutils
 
 if __name__ == '__main__':
     # prepend the "docutils root" to the Python library path
@@ -71,7 +73,27 @@
                         }).decode()
                     self.assertEqual(case_expected, output)
 
+    def test_system_msgs(self):
+        for name, cases in totest_system_msgs.items():
+            for casenum, (case_input, case_expected, case_warning) in enumerate(cases):
+                with self.subTest(id=f'totest_system_msgs[{name!r}][{casenum}]'):
+                    warnings = StringIO("")
+                    output = publish_string(
+                        source=case_input,
+                        writer=manpage.Writer(),
+                        settings_overrides={
+                            '_disable_config': True,
+                            'strict_visitor': True,
+                            'warning_stream': warnings,
+                        }).decode()
+                    self.assertEqual(case_expected, output)
+                    warnings.seek(0)
+                    self.assertEqual(
+                            case_warning,
+                            warnings.readline())
 
+
+
 document_start = r""".\" Man page generated from reStructuredText by manpage writer
 .\" from docutils 0.22b.dev.
 .
@@ -563,8 +585,11 @@
 """],
 ]
 
+# test defintion
+# [ input, expect, expected_warning ]
+totest_system_msgs ={}
 # TODO check we get an INFO not a WARNING
-totest['image'] = [
+totest_system_msgs['image'] = [
         ["""\
 text
 
@@ -581,6 +606,9 @@
 .sp
 more text
 .\\" End of generated man page.
+""",
+"""\
+<string>:3: (WARNING/2) "image" not supported
 """],
 # TODO make alt text a quote like
 #
@@ -596,7 +624,7 @@
 #   (WARNING/2) "image" not supported by "manpage" writer.
 #   Please provide an "alt" attribute with textual replacement.
 #
-totest['image-without-alt'] = [
+totest_system_msgs['image-without-alt'] = [
         ["""text
 
 .. image:: gibsnich.png
@@ -611,6 +639,9 @@
 .sp
 more text
 .\\" End of generated man page.
+""",
+"""\
+<string>:3: (WARNING/2) "image" not supported
 """],
 # TODO there should be nothing of the image in the manpage, might be decorative
 ]

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
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.