SF.net SVN: docutils:[9914] trunk/docutils/test

milde--- via Docutils-checkins <[email protected]>
Newsgroups gmane.text.docutils.cvs
Message-ID <[email protected]>
Revision: 9914
          http://sourceforge.net/p/docutils/code/9914
Author:   milde
Date:     2024-08-21 13:45:08 +0000 (Wed, 21 Aug 2024)
Log Message:
-----------
Use writer instances instead of names in test scripts.

Calling the publisher convenience functions with a component
instance instead of its name gives a slight speedup.

Also, don't specify a component argument if it is the default.

Modified Paths:
--------------
    trunk/docutils/test/test_dependencies.py
    trunk/docutils/test/test_parsers/test_docutils_xml/test_misc.py
    trunk/docutils/test/test_publisher.py
    trunk/docutils/test/test_traversals.py
    trunk/docutils/test/test_writers/test_docutils_xml.py
    trunk/docutils/test/test_writers/test_html4css1_misc.py
    trunk/docutils/test/test_writers/test_html4css1_parts.py
    trunk/docutils/test/test_writers/test_html4css1_template.py
    trunk/docutils/test/test_writers/test_html5_polyglot.py
    trunk/docutils/test/test_writers/test_html5_polyglot_misc.py
    trunk/docutils/test/test_writers/test_latex2e.py
    trunk/docutils/test/test_writers/test_latex2e_misc.py
    trunk/docutils/test/test_writers/test_manpage.py
    trunk/docutils/test/test_writers/test_null.py
    trunk/docutils/test/test_writers/test_odt.py
    trunk/docutils/test/test_writers/test_pseudoxml.py
    trunk/docutils/test/test_writers/test_s5.py

Modified: trunk/docutils/test/test_dependencies.py
===================================================================
--- trunk/docutils/test/test_dependencies.py	2024-08-21 13:44:48 UTC (rev 9913)
+++ trunk/docutils/test/test_dependencies.py	2024-08-21 13:45:08 UTC (rev 9914)
@@ -23,6 +23,7 @@
 import docutils.utils
 import docutils.io
 from docutils.parsers.rst.directives.images import PIL
+from docutils.writers import html4css1, html5_polyglot, latex2e, docutils_xml
 
 TEST_ROOT = Path(__file__).parent  # ./test/ from the docutils root
 DATA_ROOT = TEST_ROOT / 'data'
@@ -76,7 +77,7 @@
         if PIL and os.path.exists('../docs/user/rst/images/'):
             keys += ['figure-image']
         expected = [paths[key] for key in keys]
-        record, _output = self.get_record(writer='xml')
+        record, _output = self.get_record(writer=docutils_xml.Writer())
         # the order of the files is arbitrary
         self.assertEqual(sorted(expected), sorted(record))
 
@@ -89,7 +90,7 @@
         settings = {'stylesheet_path': None,
                     'stylesheet': None,
                     'report_level': 4}  # drop warning if PIL is missing
-        record, output = self.get_record(writer='html5',
+        record, output = self.get_record(writer=html5_polyglot.Writer(),
                                          settings_overrides=settings)
         # the order of the files is arbitrary
         self.assertEqual(sorted(expected), sorted(record),
@@ -105,7 +106,7 @@
             keys += ['figure-image']
         expected = [paths[key] for key in keys]
         record, output = self.get_record(
-                            writer='latex',
+                            writer=latex2e.Writer(),
                             settings_overrides=latex_settings_overwrites)
         # the order of the files is arbitrary
         self.assertEqual(sorted(expected), sorted(record),
@@ -123,22 +124,22 @@
                     'stylesheet': None}
         settings.update(latex_settings_overwrites)
         settings['embed_stylesheet'] = False
-        record, _output = self.get_record(writer='html',
+        record, _output = self.get_record(writer=html4css1.Writer(),
                                           settings_overrides=settings)
         self.assertTrue(stylesheet not in record,
                         f'{stylesheet!r} should not be in {record!r}')
-        record, _output = self.get_record(writer='latex',
+        record, _output = self.get_record(writer=latex2e.Writer(),
                                           settings_overrides=settings)
         self.assertTrue(stylesheet not in record,
                         f'{stylesheet!r} should not be in {record!r}')
 
         settings['embed_stylesheet'] = True
-        record, _output = self.get_record(writer='html',
+        record, _output = self.get_record(writer=html4css1.Writer(),
                                           settings_overrides=settings)
         self.assertTrue(stylesheet in record,
                         f'{stylesheet!r} should be in {record!r}')
         settings['embed_stylesheet'] = True
-        record, _output = self.get_record(writer='latex',
+        record, _output = self.get_record(writer=latex2e.Writer(),
                                           settings_overrides=settings)
         self.assertTrue(stylesheet in record,
                         f'{stylesheet!r} should be in {record!r}')

Modified: trunk/docutils/test/test_parsers/test_docutils_xml/test_misc.py
===================================================================
--- trunk/docutils/test/test_parsers/test_docutils_xml/test_misc.py	2024-08-21 13:44:48 UTC (rev 9913)
+++ trunk/docutils/test/test_parsers/test_docutils_xml/test_misc.py	2024-08-21 13:45:08 UTC (rev 9914)
@@ -26,9 +26,7 @@
 from docutils.core import publish_string
 from docutils.parsers import docutils_xml
 
-parser = docutils_xml.Parser()
 
-
 class XMLParserTests(unittest.TestCase):
     maxDiff = None
 
@@ -42,7 +40,8 @@
             settings = self.mysettings | settings
             for casenum, (case_input, case_expected) in enumerate(cases):
                 with self.subTest(id=f'totest[{name!r}][{casenum}]'):
-                    output = publish_string(case_input, parser=parser,
+                    output = publish_string(case_input,
+                                            parser=docutils_xml.Parser(),
                                             settings_overrides=settings)
                     self.assertEqual(case_expected, output)
 

Modified: trunk/docutils/test/test_publisher.py
===================================================================
--- trunk/docutils/test/test_publisher.py	2024-08-21 13:44:48 UTC (rev 9913)
+++ trunk/docutils/test/test_publisher.py	2024-08-21 13:45:08 UTC (rev 9914)
@@ -18,8 +18,9 @@
     sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
 
 import docutils
+import docutils.parsers.null
 from docutils import core, nodes, parsers, readers, writers
-import docutils.parsers.null
+from docutils.writers import html4css1, odf_odt, pseudoxml
 
 # DATA_ROOT is ./test/data/ from the docutils root
 DATA_ROOT = Path(__file__).parent / 'data'
@@ -227,7 +228,7 @@
                                     'warning_stream': ''}
         with self.assertRaisesRegex(docutils.utils.SystemMessage,
                                     'The ODT writer returns `bytes` '):
-            core.publish_string('test', writer='odt',
+            core.publish_string('test', writer=odf_odt.Writer(),
                                 settings_overrides=settings)
 
     def test_publish_string_deprecation_warning(self):
@@ -253,7 +254,7 @@
         # Produce the document tree.
         with self.assertWarns(PendingDeprecationWarning):
             doctree = core.publish_doctree(
-                source=test_document, reader='standalone',
+                source=test_document,
                 parser_name='restructuredtext', settings_spec=self,
                 settings_overrides={'expose_internals':
                                     ['refnames', 'do_not_expose'],
@@ -274,7 +275,7 @@
         # Write out the document:
         output = core.publish_from_doctree(
             doctree,
-            writer='pseudoxml',
+            writer=pseudoxml.Writer(),
             settings_spec=self,
             settings_overrides={'expose_internals':
                                 ['refnames', 'do_not_expose'],
@@ -285,7 +286,7 @@
         # Test publishing parts using document as the source.
         parts = core.publish_parts(
             reader='doctree', source_class=docutils.io.DocTreeInput,
-            source=doctree, source_path='test', writer='html',
+            source=doctree, source_path='test', writer=html4css1.Writer(),
             settings_spec=self)
         self.assertTrue(isinstance(parts, dict))
 
@@ -295,8 +296,6 @@
         # Produce the document tree.
         doctree = core.publish_doctree(
             source=test_document,
-            reader='standalone',
-            parser='restructuredtext',
             settings_spec=self)
         self.assertTrue(isinstance(doctree, nodes.document))
 

Modified: trunk/docutils/test/test_traversals.py
===================================================================
--- trunk/docutils/test/test_traversals.py	2024-08-21 13:44:48 UTC (rev 9913)
+++ trunk/docutils/test/test_traversals.py	2024-08-21 13:45:08 UTC (rev 9914)
@@ -68,8 +68,6 @@
         # Load some document tree in memory.
         doctree = core.publish_doctree(
             source=stop_traversal_input,
-            reader='standalone',
-            parser='restructuredtext',
             settings_spec=self)
         self.assertTrue(isinstance(doctree, nodes.document))
 

Modified: trunk/docutils/test/test_writers/test_docutils_xml.py
===================================================================
--- trunk/docutils/test/test_writers/test_docutils_xml.py	2024-08-21 13:44:48 UTC (rev 9913)
+++ trunk/docutils/test/test_writers/test_docutils_xml.py	2024-08-21 13:45:08 UTC (rev 9914)
@@ -19,6 +19,7 @@
 
 import docutils
 import docutils.core
+from docutils.writers import docutils_xml
 
 from io import StringIO
 
@@ -122,8 +123,7 @@
 
 def publish_xml(settings, source):
     return docutils.core.publish_string(source=source,
-                                       reader='standalone',
-                                       writer='docutils_xml',
+                                       writer=docutils_xml.Writer(),
                                        settings_overrides=settings)
 
 

Modified: trunk/docutils/test/test_writers/test_html4css1_misc.py
===================================================================
--- trunk/docutils/test/test_writers/test_html4css1_misc.py	2024-08-21 13:44:48 UTC (rev 9913)
+++ trunk/docutils/test/test_writers/test_html4css1_misc.py	2024-08-21 13:45:08 UTC (rev 9914)
@@ -19,6 +19,7 @@
     sys.path.insert(0, str(Path(__file__).resolve().parents[2]))
 
 from docutils import core
+from docutils.writers import html4css1
 
 # TEST_ROOT is ./test/ from the docutils root
 TEST_ROOT = Path(__file__).parents[1]
@@ -36,11 +37,11 @@
         # error handler.
         settings_overrides = {
             'output_encoding': 'latin1',
-            'stylesheet': '',
+            'stylesheet-path': '',
             '_disable_config': True,
             }
         result = bytes(core.publish_string(
-            'EUR = \u20ac', writer='html4css1',
+            'EUR = \u20ac', writer=html4css1.Writer(),
             settings_overrides=settings_overrides))
         # Encoding a euro sign with latin1 doesn't work, so the
         # xmlcharrefreplace handler is used.
@@ -49,10 +50,7 @@
 
 class MovingArgsTestCase(unittest.TestCase):
 
-    mys = {'stylesheet_path': '',
-           # 'embed_stylesheet': False,
-           '_disable_config': True,
-           }
+    mys = {'_disable_config': True}
 
     def test_definition_list_item_classes(self):
         # Do not drop class arguments for the definition list item.
@@ -66,7 +64,7 @@
 second term:
   second def
 """
-        result = core.publish_string(data, writer='html4css1',
+        result = core.publish_string(data, writer=html4css1.Writer(),
                                      settings_overrides=self.mys)
         self.assertIn(b'<dt class="for the second item">second term:</dt>',
                       result)
@@ -83,7 +81,7 @@
 second term:
   second def
 """
-        result = core.publish_string(data, writer='html4css1',
+        result = core.publish_string(data, writer=html4css1.Writer(),
                                      settings_overrides=self.mys)
         self.assertIn(b'<dt id="second-item">second term:</dt>',
                       result)
@@ -98,7 +96,7 @@
     def test_default_stylesheet(self):
         # default style sheet, embedded
         mys = {'_disable_config': True}
-        styles = core.publish_parts(self.data, writer='html4css1',
+        styles = core.publish_parts(self.data, writer=html4css1.Writer(),
                                     settings_overrides=mys)['stylesheet']
         self.assertIn('Default cascading style sheet '
                       'for the HTML output of Docutils.', styles)
@@ -107,7 +105,7 @@
         # default style sheet, linked
         mys = {'_disable_config': True,
                'embed_stylesheet': False}
-        styles = core.publish_parts(self.data, writer='html4css1',
+        styles = core.publish_parts(self.data, writer=html4css1.Writer(),
                                     settings_overrides=mys)['stylesheet']
         self.assertIn('docutils/writers/html4css1/html4css1.css', styles)
 
@@ -116,7 +114,7 @@
         mys = {'_disable_config': True,
                'embed_stylesheet': False,
                'stylesheet_path': 'html4css1.css, math.css'}
-        styles = core.publish_parts(self.data, writer='html4css1',
+        styles = core.publish_parts(self.data, writer=html4css1.Writer(),
                                     settings_overrides=mys)['stylesheet']
         self.assertIn('docutils/writers/html4css1/html4css1.css', styles)
         self.assertIn('docutils/writers/html5_polyglot/math.css', styles)
@@ -127,7 +125,7 @@
                'embed_stylesheet': False,
                'stylesheet_path': 'html4css1.css, '
                'data/ham.css'}
-        styles = core.publish_parts(self.data, writer='html4css1',
+        styles = core.publish_parts(self.data, writer=html4css1.Writer(),
                                     settings_overrides=mys)['stylesheet']
         self.assertIn('docutils/writers/html4css1/html4css1.css', styles)
         self.assertIn('href="data/ham.css"', styles)
@@ -139,7 +137,7 @@
                    TEST_ROOT / '../docutils/writers/html4css1/',
                    DATA_ROOT),
                'stylesheet_path': 'html4css1.css, ham.css'}
-        styles = core.publish_parts(self.data, writer='html4css1',
+        styles = core.publish_parts(self.data, writer=html4css1.Writer(),
                                     settings_overrides=mys)['stylesheet']
         if (TEST_ROOT / '../docutils/writers/html4css1/').is_dir():
             self.assertIn('docutils/writers/html4css1/html4css1.css', styles)
@@ -152,7 +150,7 @@
                    TEST_ROOT / '../docutils/writers/html4css1/',
                    DATA_ROOT),
                'stylesheet_path': 'ham.css'}
-        styles = core.publish_parts(self.data, writer='html4css1',
+        styles = core.publish_parts(self.data, writer=html4css1.Writer(),
                                     settings_overrides=mys)['stylesheet']
         self.assertIn('dl.docutils dd {\n  margin-bottom: 0.5em }', styles)
 
@@ -175,7 +173,7 @@
     def test_math_output_default(self):
         # HTML with math.css stylesheet (since 0.11)
         mys = {'_disable_config': True}
-        styles = core.publish_parts(self.data, writer='html4css1',
+        styles = core.publish_parts(self.data, writer=html4css1.Writer(),
                                     settings_overrides=mys)['stylesheet']
         self.assertIn('convert LaTeX equations to HTML output.', styles)
 
@@ -185,7 +183,7 @@
         mys = {'_disable_config': True,
                'report_level': 3,
                'math_output': 'MathJax'}
-        head = core.publish_parts(self.data, writer='html4css1',
+        head = core.publish_parts(self.data, writer=html4css1.Writer(),
                                   settings_overrides=mys)['head']
         self.assertIn(self.mathjax_script % self.default_mathjax_url, head)
 
@@ -194,7 +192,7 @@
         mys = {'_disable_config': True,
                'math_output':
                'mathjax %s' % self.custom_mathjax_url}
-        head = core.publish_parts(self.data, writer='html4css1',
+        head = core.publish_parts(self.data, writer=html4css1.Writer(),
                                   settings_overrides=mys)['head']
         self.assertIn(self.mathjax_script % self.custom_mathjax_url, head)
 
@@ -201,7 +199,7 @@
     def test_math_output_html(self):
         mys = {'_disable_config': True,
                'math_output': 'HTML'}
-        head = core.publish_parts(self.data, writer='html4css1',
+        head = core.publish_parts(self.data, writer=html4css1.Writer(),
                                   settings_overrides=mys)['head']
         # There should be no MathJax script when math_output is not MathJax
         self.assertNotIn('MathJax.js', head)
@@ -213,7 +211,7 @@
                    TEST_ROOT,
                    os.path.join(TEST_ROOT, 'functional/input/data')),
                'embed_stylesheet': False}
-        styles = core.publish_parts(self.data, writer='html4css1',
+        styles = core.publish_parts(self.data, writer=html4css1.Writer(),
                                     settings_overrides=mys)['stylesheet']
         self.assertEqual(f"""\
 <link rel="stylesheet" href="{html4css1_css}" type="text/css" />
@@ -223,7 +221,7 @@
 
     def test_math_output_mathjax_no_math(self):
         # There should be no math script when text does not contain math
-        head = core.publish_parts('No math.', writer='html4css1')['head']
+        head = core.publish_parts('No math.', writer=html4css1.Writer())['head']
         self.assertNotIn('MathJax', head)
 
 

Modified: trunk/docutils/test/test_writers/test_html4css1_parts.py
===================================================================
--- trunk/docutils/test/test_writers/test_html4css1_parts.py	2024-08-21 13:44:48 UTC (rev 9913)
+++ trunk/docutils/test/test_writers/test_html4css1_parts.py	2024-08-21 13:45:08 UTC (rev 9914)
@@ -24,8 +24,8 @@
 import docutils
 import docutils.core
 from docutils.parsers.rst.directives.images import PIL
+from docutils.writers import html4css1
 
-
 ROOT_PREFIX = (Path(__file__).parent.parent/'functional'/'input').as_posix()
 if PIL:
     SCALING_OUTPUT = 'style="width: 32.0px; height: 32.0px;" '
@@ -41,17 +41,16 @@
     maxDiff = None
 
     def test_publish(self):
-        writer = 'html4'
         for name, (settings_overrides, cases) in totest.items():
             for casenum, (case_input, case_expected) in enumerate(cases):
                 with self.subTest(id=f'totest[{name!r}][{casenum}]'):
                     parts = docutils.core.publish_parts(
                         source=case_input,
-                        writer=writer,
+                        writer=html4css1.Writer(),
                         settings_overrides={
                             '_disable_config': True,
                             'strict_visitor': True,
-                            'stylesheet': '',
+                            'stylesheet_path': '',
                             **settings_overrides,
                         }
                     )
@@ -110,8 +109,7 @@
 
 totest = {}
 
-totest['title_promotion'] = ({'stylesheet_path': '',
-                              'embed_stylesheet': False}, [
+totest['title_promotion'] = ({}, [
 ["""\
 Simple String
 """,
@@ -252,9 +250,7 @@
 }]
 ])
 
-totest['no_title_promotion'] = ({'doctitle_xform': False,
-                                 'stylesheet_path': '',
-                                 'embed_stylesheet': False}, [
+totest['no_title_promotion'] = ({'doctitle_xform': False}, [
 ["""\
 Simple String
 """,
@@ -416,9 +412,7 @@
 ],
 ])
 
-totest['root_prefix'] = ({'root_prefix': ROOT_PREFIX,
-                          'stylesheet_path': '',
-                          'embed_stylesheet': False}, [
+totest['root_prefix'] = ({'root_prefix': ROOT_PREFIX}, [
 
 ["""\
 .. image:: /data/blue%20square.png

Modified: trunk/docutils/test/test_writers/test_html4css1_template.py
===================================================================
--- trunk/docutils/test/test_writers/test_html4css1_template.py	2024-08-21 13:44:48 UTC (rev 9913)
+++ trunk/docutils/test/test_writers/test_html4css1_template.py	2024-08-21 13:45:08 UTC (rev 9914)
@@ -21,6 +21,7 @@
 
 import docutils
 from docutils.core import publish_string
+from docutils.writers import html4css1
 
 # TEST_ROOT is ./test/ from the docutils root
 TEST_ROOT = Path(__file__).parents[1]
@@ -29,7 +30,6 @@
 class WriterPublishTestCase(unittest.TestCase):
     # maxDiff = None
     def test_publish(self):
-        writer = 'html4'
         template_path = TEST_ROOT / 'data/full-template.txt'
         for name, cases in totest.items():
             for casenum, (case_input, case_expected) in enumerate(cases):
@@ -36,7 +36,7 @@
                 with self.subTest(id=f'totest[{name!r}][{casenum}]'):
                     output = publish_string(
                         source=case_input,
-                        writer=writer,
+                        writer=html4css1.Writer(),
                         settings_overrides={
                             '_disable_config': True,
                             'strict_visitor': True,

Modified: trunk/docutils/test/test_writers/test_html5_polyglot.py
===================================================================
--- trunk/docutils/test/test_writers/test_html5_polyglot.py	2024-08-21 13:44:48 UTC (rev 9913)
+++ trunk/docutils/test/test_writers/test_html5_polyglot.py	2024-08-21 13:45:08 UTC (rev 9914)
@@ -23,6 +23,7 @@
 import docutils.core
 from docutils.parsers.rst.directives.images import PIL
 from docutils.utils.code_analyzer import with_pygments
+from docutils.writers import html5_polyglot
 
 if with_pygments:
     import pygments
@@ -71,13 +72,12 @@
     def test_publish(self):
         if not with_pygments:
             del totest['syntax_highlight']
-        writer = 'html5'
         for name, (settings_overrides, cases) in totest.items():
             for casenum, (case_input, case_expected) in enumerate(cases):
                 with self.subTest(id=f'totest[{name!r}][{casenum}]'):
                     parts = docutils.core.publish_parts(
                         source=case_input,
-                        writer=writer,
+                        writer=html5_polyglot.Writer(),
                         settings_overrides={
                             '_disable_config': True,
                             'strict_visitor': True,

Modified: trunk/docutils/test/test_writers/test_html5_polyglot_misc.py
===================================================================
--- trunk/docutils/test/test_writers/test_html5_polyglot_misc.py	2024-08-21 13:44:48 UTC (rev 9913)
+++ trunk/docutils/test/test_writers/test_html5_polyglot_misc.py	2024-08-21 13:45:08 UTC (rev 9914)
@@ -19,6 +19,7 @@
     sys.path.insert(0, str(Path(__file__).resolve().parents[2]))
 
 from docutils import core
+from docutils.writers import html5_polyglot
 
 # TEST_ROOT is ./test/ from the docutils root
 TEST_ROOT = Path(__file__).parents[1]
@@ -39,7 +40,7 @@
             'stylesheet_path': '',
             '_disable_config': True}
         result = core.publish_string(
-            'EUR = \u20ac', writer='html5_polyglot',
+            'EUR = \u20ac', writer=html5_polyglot.Writer(),
             settings_overrides=settings_overrides)
         # Encoding a euro sign with latin1 doesn't work, so the
         # xmlcharrefreplace handler is used.
@@ -64,7 +65,7 @@
 second term:
   second def
 """
-        result = core.publish_string(data, writer='html5_polyglot',
+        result = core.publish_string(data, writer=html5_polyglot.Writer(),
                                      settings_overrides=self.mys).decode()
         self.assertIn('<dt class="for the second item">second term:</dt>',
                       result)
@@ -81,7 +82,7 @@
 second term:
   second def
 """
-        result = core.publish_string(data, writer='html5_polyglot',
+        result = core.publish_string(data, writer=html5_polyglot.Writer(),
                                      settings_overrides=self.mys).decode()
         self.assertIn('<dt id="second-item">second term:</dt>',
                       result)
@@ -96,7 +97,7 @@
     def test_default_stylesheet(self):
         # default style sheet, embedded
         mys = {'_disable_config': True}
-        styles = core.publish_parts(self.data, writer='html5_polyglot',
+        styles = core.publish_parts(self.data, writer=html5_polyglot.Writer(),
                                     settings_overrides=mys)['stylesheet']
         self.assertIn('Minimal style sheet for the HTML output of Docutils.',
                       styles)
@@ -105,7 +106,7 @@
         # default style sheet, linked
         mys = {'_disable_config': True,
                'embed_stylesheet': False}
-        styles = core.publish_parts(self.data, writer='html5_polyglot',
+        styles = core.publish_parts(self.data, writer=html5_polyglot.Writer(),
                                     settings_overrides=mys)['stylesheet']
         self.assertIn('docutils/writers/html5_polyglot/minimal.css', styles)
 
@@ -114,7 +115,7 @@
         mys = {'_disable_config': True,
                'embed_stylesheet': False,
                'stylesheet_path': 'minimal.css, math.css'}
-        styles = core.publish_parts(self.data, writer='html5_polyglot',
+        styles = core.publish_parts(self.data, writer=html5_polyglot.Writer(),
                                     settings_overrides=mys)['stylesheet']
         self.assertIn('docutils/writers/html5_polyglot/minimal.css', styles)
         self.assertIn('docutils/writers/html5_polyglot/math.css', styles)
@@ -125,7 +126,7 @@
                'embed_stylesheet': False,
                'stylesheet_path': 'minimal.css, '
                'data/ham.css'}
-        styles = core.publish_parts(self.data, writer='html5_polyglot',
+        styles = core.publish_parts(self.data, writer=html5_polyglot.Writer(),
                                     settings_overrides=mys)['stylesheet']
         self.assertIn('docutils/writers/html5_polyglot/minimal.css', styles)
         self.assertIn('href="data/ham.css"', styles)
@@ -137,7 +138,7 @@
                    TEST_ROOT / '../docutils/writers/html5_polyglot/',
                    DATA_ROOT),
                'stylesheet_path': 'minimal.css, ham.css'}
-        styles = core.publish_parts(self.data, writer='html5_polyglot',
+        styles = core.publish_parts(self.data, writer=html5_polyglot.Writer(),
                                     settings_overrides=mys)['stylesheet']
         if (TEST_ROOT / '../docutils/writers/html5_polyglot/').is_dir():
             self.assertIn('docutils/writers/html5_polyglot/minimal.css',
@@ -151,7 +152,7 @@
                    TEST_ROOT / '../docutils/writers/html5_polyglot/',
                    DATA_ROOT),
                'stylesheet_path': 'ham.css'}
-        styles = core.publish_parts(self.data, writer='html5_polyglot',
+        styles = core.publish_parts(self.data, writer=html5_polyglot.Writer(),
                                     settings_overrides=mys)['stylesheet']
         self.assertIn('dl.docutils dd {\n  margin-bottom: 0.5em }', styles)
 
@@ -163,7 +164,8 @@
                        }
         with self.assertWarnsRegex(FutureWarning,
                                    '"embed_images"\n  will be removed'):
-            core.publish_string('warnings test', writer='html5',
+            core.publish_string('warnings test',
+                                writer=html5_polyglot.Writer(),
                                 settings_overrides=my_settings)
 
 
@@ -186,7 +188,7 @@
     def test_math_output_default(self):
         # default math output is MathML (since 0.22)
         mys = {'_disable_config': True}
-        fragment = core.publish_parts(self.data, writer='html5_polyglot',
+        fragment = core.publish_parts(self.data, writer=html5_polyglot.Writer(),
                                       settings_overrides=mys)['fragment']
         self.assertIn('<mn>42</mn>', fragment)
 
@@ -196,7 +198,7 @@
         mys = {'_disable_config': True,
                'report_level': 3,
                'math_output': 'MathJax'}
-        head = core.publish_parts(self.data, writer='html5_polyglot',
+        head = core.publish_parts(self.data, writer=html5_polyglot.Writer(),
                                   settings_overrides=mys)['head']
         self.assertIn(self.mathjax_script % self.default_mathjax_url, head)
 
@@ -205,7 +207,7 @@
         mys = {'_disable_config': True,
                'math_output':
                'mathjax %s' % self.custom_mathjax_url}
-        head = core.publish_parts(self.data, writer='html5_polyglot',
+        head = core.publish_parts(self.data, writer=html5_polyglot.Writer(),
                                   settings_overrides=mys)['head']
         self.assertIn(self.mathjax_script % self.custom_mathjax_url, head)
 
@@ -212,7 +214,7 @@
     def test_math_output_html(self):
         mys = {'_disable_config': True,
                'math_output': 'HTML'}
-        head = core.publish_parts(self.data, writer='html5_polyglot',
+        head = core.publish_parts(self.data, writer=html5_polyglot.Writer(),
                                   settings_overrides=mys)['head']
         # There should be no MathJax script when math_output is not MathJax
         self.assertNotIn('MathJax.js', head)
@@ -224,7 +226,7 @@
                    TEST_ROOT,
                    TEST_ROOT / 'functional/input/data'),
                'embed_stylesheet': False}
-        styles = core.publish_parts(self.data, writer='html5_polyglot',
+        styles = core.publish_parts(self.data, writer=html5_polyglot.Writer(),
                                     settings_overrides=mys)['stylesheet']
         self.assertEqual(f"""\
 <link rel="stylesheet" href="{minimal_css}" type="text/css" />
@@ -235,7 +237,7 @@
 
     def test_math_output_mathjax_no_math(self):
         # There should be no math script when text does not contain math
-        head = core.publish_parts('No math.', writer='html5_polyglot')['head']
+        head = core.publish_parts('No math.', writer=html5_polyglot.Writer())['head']
         self.assertNotIn('MathJax', head)
 
 

Modified: trunk/docutils/test/test_writers/test_latex2e.py
===================================================================
--- trunk/docutils/test/test_writers/test_latex2e.py	2024-08-21 13:44:48 UTC (rev 9913)
+++ trunk/docutils/test/test_writers/test_latex2e.py	2024-08-21 13:45:08 UTC (rev 9914)
@@ -19,6 +19,7 @@
     sys.path.insert(0, str(Path(__file__).resolve().parents[2]))
 
 from docutils.core import publish_string
+from docutils.writers import latex2e
 
 # DATA_ROOT is ./test/data from the docutils root
 DATA_ROOT = Path(__file__).resolve().parents[1] / 'data'
@@ -35,7 +36,6 @@
 class WriterPublishTestCase(unittest.TestCase):
 
     maxDiff = None
-    writer = 'latex'
     settings = {
         '_disable_config': True,
         'strict_visitor': True,
@@ -49,7 +49,7 @@
             for casenum, (rst_input, expected) in enumerate(cases):
                 with self.subTest(id=f'samples_default[{name!r}][{casenum}]'):
                     output = publish_string(source=rst_input,
-                                            writer=self.writer,
+                                            writer=latex2e.Writer(),
                                             settings_overrides=settings)
                     output = output.decode()
                     self.assertEqual(expected, output)

Modified: trunk/docutils/test/test_writers/test_latex2e_misc.py
===================================================================
--- trunk/docutils/test/test_writers/test_latex2e_misc.py	2024-08-21 13:44:48 UTC (rev 9913)
+++ trunk/docutils/test/test_writers/test_latex2e_misc.py	2024-08-21 13:45:08 UTC (rev 9914)
@@ -27,6 +27,7 @@
     sys.path.insert(0, str(Path(__file__).resolve().parents[2]))
 
 from docutils import core
+from docutils.writers import latex2e
 
 # TEST_ROOT is ./test/ from the docutils root
 TEST_ROOT = Path(__file__).parents[1]
@@ -88,7 +89,7 @@
         doctree = core.publish_doctree(sample_toc,
                                        settings_overrides=settings)
         result = core.publish_from_doctree(doctree,
-                                           writer='latex',
+                                           writer=latex2e.Writer(),
                                            settings_overrides=settings)
         self.assertNotIn(r'\item \hyperref[foo]{foo}', result)
         self.assertIn(r'\tableofcontents', result)
@@ -97,7 +98,7 @@
         """Check for the presence of documented parts.
         """
         parts = core.publish_parts(sample_multiterm,
-                                   writer='latex',
+                                   writer=latex2e.Writer(),
                                    settings_overrides=self.settings)
         documented_parts = [
             'abstract',
@@ -135,11 +136,11 @@
                     }
         with self.assertWarnsRegex(FutureWarning,
                                    '"legacy_column_widths" will change'):
-            core.publish_string('warnings test', writer='latex',
+            core.publish_string('warnings test', writer=latex2e.Writer(),
                                 settings_overrides=settings)
         with self.assertWarnsRegex(FutureWarning,
                                    '"use_latex_citations" will change'):
-            core.publish_string('warnings test', writer='latex',
+            core.publish_string('warnings test', writer=latex2e.Writer(),
                                 settings_overrides=settings)
 
 

Modified: trunk/docutils/test/test_writers/test_manpage.py
===================================================================
--- trunk/docutils/test/test_writers/test_manpage.py	2024-08-21 13:44:48 UTC (rev 9913)
+++ trunk/docutils/test/test_writers/test_manpage.py	2024-08-21 13:45:08 UTC (rev 9914)
@@ -17,7 +17,7 @@
     sys.path.insert(0, str(Path(__file__).resolve().parents[2]))
 
 from docutils.core import publish_string
-from docutils.writers.manpage import insert_URI_breakpoints
+from docutils.writers import manpage
 
 URI_tests = (
         ("///abc.de", r"///\:abc.de"),
@@ -35,7 +35,7 @@
 
     def test_insert(self):
         for t in URI_tests:
-            got = insert_URI_breakpoints(t[0])
+            got = manpage.insert_URI_breakpoints(t[0])
             self.assertEqual(t[1], got)
 
 
@@ -44,13 +44,12 @@
     maxDiff = None
 
     def test_publish(self):
-        writer = 'manpage'
         for name, cases in totest.items():
             for casenum, (case_input, case_expected) in enumerate(cases):
                 with self.subTest(id=f'totest[{name!r}][{casenum}]'):
                     output = publish_string(
                         source=case_input,
-                        writer=writer,
+                        writer=manpage.Writer(),
                         settings_overrides={
                             '_disable_config': True,
                             'strict_visitor': True,
@@ -58,13 +57,12 @@
                     self.assertEqual(case_expected, output)
 
     def test_reference_macros(self):
-        writer = 'manpage'
         for name, cases in totest_refs.items():
             for casenum, (case_input, case_expected) in enumerate(cases):
                 with self.subTest(id=f'totest_refs[{name!r}][{casenum}]'):
                     output = publish_string(
                         source=case_input,
-                        writer=writer,
+                        writer=manpage.Writer(),
                         settings_overrides={
                             '_disable_config': True,
                             'strict_visitor': True,
@@ -117,7 +115,7 @@
          document_start + indend_macros + """.TH "" "" "" ""
 .SH Name
  \\- \n\
-External hyperlinks, like 
+External hyperlinks, like \n\
 .UR https://www.python.org/
 Python
 .UE

Modified: trunk/docutils/test/test_writers/test_null.py
===================================================================
--- trunk/docutils/test/test_writers/test_null.py	2024-08-21 13:44:48 UTC (rev 9913)
+++ trunk/docutils/test/test_writers/test_null.py	2024-08-21 13:45:08 UTC (rev 9914)
@@ -18,17 +18,17 @@
     sys.path.insert(0, str(Path(__file__).resolve().parents[2]))
 
 from docutils.core import publish_string
+from docutils.writers import null
 
 
 class WriterPublishTestCase(unittest.TestCase):
     def test_publish(self):
-        writer = 'null'
         for name, cases in totest.items():
             for casenum, (case_input, case_expected) in enumerate(cases):
                 with self.subTest(id=f'totest[{name!r}][{casenum}]'):
                     output = publish_string(
                         source=case_input,
-                        writer=writer,
+                        writer=null.Writer(),
                         settings_overrides={
                             '_disable_config': True,
                             'strict_visitor': True,

Modified: trunk/docutils/test/test_writers/test_odt.py
===================================================================
--- trunk/docutils/test/test_writers/test_odt.py	2024-08-21 13:44:48 UTC (rev 9913)
+++ trunk/docutils/test/test_writers/test_odt.py	2024-08-21 13:45:08 UTC (rev 9914)
@@ -45,6 +45,7 @@
 
 import docutils
 import docutils.core
+from docutils.writers import odf_odt
 
 # FUNCTIONAL_ROOT is ./test/functional/ from the docutils root
 FUNCTIONAL_ROOT = os.path.abspath(os.path.join(__file__, '..', '..', 'functional'))
@@ -75,11 +76,10 @@
             settings_overrides['language_code'] = 'en-US'
 
         result = docutils.core.publish_string(
-            source=source,
-            source_path=input_path,
-            reader='standalone',
-            writer='odf_odt',
-            settings_overrides=settings_overrides)
+                     source=source,
+                     source_path=input_path,
+                     writer=odf_odt.Writer(),
+                     settings_overrides=settings_overrides)
         # msg = 'file length not equal: expected length: %d  actual length: %d' % (
         #           len(expected), len(result), )
         # self.assertEqual(str(len(result)), str(len(expected)))

Modified: trunk/docutils/test/test_writers/test_pseudoxml.py
===================================================================
--- trunk/docutils/test/test_writers/test_pseudoxml.py	2024-08-21 13:44:48 UTC (rev 9913)
+++ trunk/docutils/test/test_writers/test_pseudoxml.py	2024-08-21 13:45:08 UTC (rev 9914)
@@ -18,6 +18,7 @@
     sys.path.insert(0, str(Path(__file__).resolve().parents[2]))
 
 from docutils.core import publish_string
+from docutils.writers import pseudoxml
 
 
 class WriterPublishTestCase(unittest.TestCase):
@@ -24,14 +25,12 @@
     maxDiff = None
 
     def test_publish(self):
-        writer = 'pseudoxml'
-
         for name, cases in totest.items():
             for casenum, (case_input, case_expected) in enumerate(cases):
                 with self.subTest(id=f'totest[{name!r}][{casenum}]'):
                     output = publish_string(
                         source=case_input,
-                        writer=writer,
+                        writer=pseudoxml.Writer(),
                         settings_overrides={
                             '_disable_config': True,
                             'strict_visitor': True,
@@ -43,7 +42,7 @@
                 with self.subTest(id=f'totest_detailed[{name!r}][{casenum}]'):
                     output = publish_string(
                         source=case_input,
-                        writer=writer,
+                        writer=pseudoxml.Writer(),
                         settings_overrides={
                             '_disable_config': True,
                             'strict_visitor': True,

Modified: trunk/docutils/test/test_writers/test_s5.py
===================================================================
--- trunk/docutils/test/test_writers/test_s5.py	2024-08-21 13:44:48 UTC (rev 9913)
+++ trunk/docutils/test/test_writers/test_s5.py	2024-08-21 13:45:08 UTC (rev 9914)
@@ -21,11 +21,11 @@
 
 import docutils
 from docutils.core import publish_string
+from docutils.writers import s5_html
 
 
 class WriterPublishTestCase(unittest.TestCase):
     def test_publish(self):
-        writer = 's5'
         settings = {
             '_disable_config': True,
             'strict_visitor': True,
@@ -38,7 +38,7 @@
                 with self.subTest(id=f'totest_1[{name!r}][{casenum}]'):
                     output = publish_string(
                         source=case_input,
-                        writer=writer,
+                        writer=s5_html.Writer(),
                         settings_overrides=settings.copy()
                         ).decode()
                     self.assertEqual(case_expected, output)
@@ -50,7 +50,7 @@
                 with self.subTest(id=f'totest_2[{name!r}][{casenum}]'):
                     output = publish_string(
                         source=case_input,
-                        writer=writer,
+                        writer=s5_html.Writer(),
                         settings_overrides=settings.copy()
                         ).decode()
                     self.assertEqual(case_expected, output)

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.