SF.net SVN: docutils:[9748 ] trunk

milde--- via Docutils-checkins <[email protected]>
Newsgroups gmane.text.docutils.cvs
Message-ID <[email protected]>
Revision: 9748
          http://sourceforge.net/p/docutils/code/9748
Author:   milde
Date:     2024-06-08 08:08:37 +0000 (Sat, 08 Jun 2024)
Log Message:
-----------
Small adjustments to writer tests.

Use `pathlib` for path operations.

Make test scripts executable.

Ensure the local `docutils` version is imported/tested.

Modified Paths:
--------------
    trunk/.flake8
    trunk/docutils/.flake8
    trunk/docutils/test/test_writers/test_get_writer_class.py
    trunk/docutils/test/test_writers/test_html4css1_misc.py
    trunk/docutils/test/test_writers/test_html4css1_template.py
    trunk/docutils/test/test_writers/test_html5_polyglot_misc.py
    trunk/docutils/test/test_writers/test_html5_template.py
    trunk/docutils/test/test_writers/test_manpage.py

Property Changed:
----------------
    trunk/docutils/test/test_writers/test_get_writer_class.py
    trunk/docutils/test/test_writers/test_html5_polyglot_misc.py
    trunk/docutils/test/test_writers/test_html5_template.py
    trunk/docutils/test/test_writers/test_manpage.py

Modified: trunk/.flake8
===================================================================
--- trunk/.flake8	2024-06-07 12:48:23 UTC (rev 9747)
+++ trunk/.flake8	2024-06-08 08:08:37 UTC (rev 9748)
@@ -64,8 +64,8 @@
   docutils/test/test_readers/test_pep/*:E122,E128,E501
   docutils/test/test_transforms/*:E122,E124,E128,E501
   docutils/test/test_writers/*:E122,E124,E128,E501
-  # test output contains trailing whitespace
-  docutils/test/test_writers/test_manpage.py:E128,W291
+  # test output contains trailing whitespace, long lines, operator at end
+  docutils/test/test_writers/test_manpage.py:E128,W291,E501,W504
 
   # ignore long line in string templates
   docutils/tools/dev/generate_punctuation_chars.py:E501

Modified: trunk/docutils/.flake8
===================================================================
--- trunk/docutils/.flake8	2024-06-07 12:48:23 UTC (rev 9747)
+++ trunk/docutils/.flake8	2024-06-08 08:08:37 UTC (rev 9748)
@@ -64,8 +64,8 @@
   test/test_readers/test_pep/*:E122,E128,E501
   test/test_transforms/*:E122,E124,E128,E501
   test/test_writers/*:E122,E124,E128,E501
-  # test output contains trailing whitespace
-  test/test_writers/test_manpage.py:E128,W291
+  # test output contains trailing whitespace, long lines, operator at end
+  test/test_writers/test_manpage.py:E128,W291,E501,W504
 
   # ignore long line in string templates
   tools/dev/generate_punctuation_chars.py:E501

Index: trunk/docutils/test/test_writers/test_get_writer_class.py
===================================================================
--- trunk/docutils/test/test_writers/test_get_writer_class.py	2024-06-07 12:48:23 UTC (rev 9747)
+++ trunk/docutils/test/test_writers/test_get_writer_class.py	2024-06-08 08:08:37 UTC (rev 9748)

Property changes on: trunk/docutils/test/test_writers/test_get_writer_class.py
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Modified: trunk/docutils/test/test_writers/test_html4css1_misc.py
===================================================================
--- trunk/docutils/test/test_writers/test_html4css1_misc.py	2024-06-07 12:48:23 UTC (rev 9747)
+++ trunk/docutils/test/test_writers/test_html4css1_misc.py	2024-06-08 08:08:37 UTC (rev 9748)
@@ -9,18 +9,24 @@
 """
 
 import os
+from pathlib import Path
+import sys
 import unittest
 
+if __name__ == '__main__':
+    # prepend the "docutils root" to the Python library path
+    # so we import the local `docutils` package.
+    sys.path.insert(0, str(Path(__file__).resolve().parents[2]))
+
 from docutils import core
 
 # TEST_ROOT is ./test/ from the docutils root
-TEST_ROOT = os.path.abspath(os.path.join(__file__, '..', '..'))
-# DATA_ROOT is ./test/data/ from the docutils root
-DATA_ROOT = os.path.join(TEST_ROOT, 'data')
+TEST_ROOT = Path(__file__).parents[1]
+DATA_ROOT = TEST_ROOT / 'data'
 
 
-def relpath(*parts):
-    return os.path.relpath(os.path.join(*parts), os.getcwd()).replace('\\', '/')
+def relpath(path):
+    return os.path.relpath(path, os.getcwd()).replace('\\', '/')
 
 
 class EncodingTestCase(unittest.TestCase):
@@ -83,7 +89,7 @@
                       result)
 
 
-ham_css = relpath(DATA_ROOT, 'ham.css')
+ham_css = relpath(DATA_ROOT/'ham.css')
 
 
 class SettingsTestCase(unittest.TestCase):
@@ -130,12 +136,12 @@
         mys = {'_disable_config': True,
                'embed_stylesheet': False,
                'stylesheet_dirs': (
-                   os.path.join(TEST_ROOT, '../docutils/writers/html4css1/'),
+                   TEST_ROOT / '../docutils/writers/html4css1/',
                    DATA_ROOT),
                'stylesheet_path': 'html4css1.css, ham.css'}
         styles = core.publish_parts(self.data, writer_name='html4css1',
                                     settings_overrides=mys)['stylesheet']
-        if os.path.isdir(os.path.join(TEST_ROOT, '../docutils/writers/html4css1/')):
+        if (TEST_ROOT / '../docutils/writers/html4css1/').is_dir():
             self.assertIn('docutils/writers/html4css1/html4css1.css', styles)
         self.assertIn(f'href="{ham_css}"', styles)
 
@@ -143,7 +149,7 @@
         mys = {'_disable_config': True,
                'embed_stylesheet': True,
                'stylesheet_dirs': (
-                   os.path.join(TEST_ROOT, '../docutils/writers/html4css1/'),
+                   TEST_ROOT / '../docutils/writers/html4css1/',
                    DATA_ROOT),
                'stylesheet_path': 'ham.css'}
         styles = core.publish_parts(self.data, writer_name='html4css1',
@@ -151,8 +157,8 @@
         self.assertIn('dl.docutils dd {\n  margin-bottom: 0.5em }', styles)
 
 
-html4css1_css = relpath(TEST_ROOT, 'functional/input/data/html4css1.css')
-math_css = relpath(TEST_ROOT, 'functional/input/data/math.css')
+html4css1_css = relpath(TEST_ROOT/'functional/input/data/html4css1.css')
+math_css = relpath(TEST_ROOT/'functional/input/data/math.css')
 
 
 class MathTestCase(unittest.TestCase):

Modified: trunk/docutils/test/test_writers/test_html4css1_template.py
===================================================================
--- trunk/docutils/test/test_writers/test_html4css1_template.py	2024-06-07 12:48:23 UTC (rev 9747)
+++ trunk/docutils/test/test_writers/test_html4css1_template.py	2024-06-08 08:08:37 UTC (rev 9748)
@@ -23,7 +23,7 @@
 from docutils.core import publish_string
 
 # TEST_ROOT is ./test/ from the docutils root
-TEST_ROOT = os.path.abspath(os.path.join(__file__, '..', '..'))
+TEST_ROOT = Path(__file__).parents[1]
 
 
 class WriterPublishTestCase(unittest.TestCase):
@@ -30,7 +30,7 @@
     # maxDiff = None
     def test_publish(self):
         writer_name = 'html4'
-        template_path = os.path.join(TEST_ROOT, 'data', 'full-template.txt')
+        template_path = TEST_ROOT / 'data/full-template.txt'
         for name, cases in totest.items():
             for casenum, (case_input, case_expected) in enumerate(cases):
                 with self.subTest(id=f'totest[{name!r}][{casenum}]'):

Modified: trunk/docutils/test/test_writers/test_html5_polyglot_misc.py
===================================================================
--- trunk/docutils/test/test_writers/test_html5_polyglot_misc.py	2024-06-07 12:48:23 UTC (rev 9747)
+++ trunk/docutils/test/test_writers/test_html5_polyglot_misc.py	2024-06-08 08:08:37 UTC (rev 9748)
@@ -21,13 +21,12 @@
 from docutils import core
 
 # TEST_ROOT is ./test/ from the docutils root
-TEST_ROOT = os.path.abspath(os.path.join(__file__, '..', '..'))
-# DATA_ROOT is ./test/data/ from the docutils root
-DATA_ROOT = os.path.join(TEST_ROOT, 'data')
+TEST_ROOT = Path(__file__).parents[1]
+DATA_ROOT = TEST_ROOT / 'data'
 
 
-def relpath(*parts):
-    return os.path.relpath(os.path.join(*parts), os.getcwd()).replace('\\', '/')
+def relpath(path):
+    return os.path.relpath(path, os.getcwd()).replace('\\', '/')
 
 
 class EncodingTestCase(unittest.TestCase):
@@ -89,7 +88,7 @@
                       result)
 
 
-ham_css = relpath(DATA_ROOT, 'ham.css')
+ham_css = relpath(DATA_ROOT / 'ham.css')
 
 
 class SettingsTestCase(unittest.TestCase):
@@ -136,12 +135,12 @@
         mys = {'_disable_config': True,
                'embed_stylesheet': False,
                'stylesheet_dirs': (
-                   os.path.join(TEST_ROOT, '../docutils/writers/html5_polyglot/'),
+                   TEST_ROOT / '../docutils/writers/html5_polyglot/',
                    DATA_ROOT),
                'stylesheet_path': 'minimal.css, ham.css'}
         styles = core.publish_parts(self.data, writer_name='html5_polyglot',
                                     settings_overrides=mys)['stylesheet']
-        if os.path.isdir(os.path.join(TEST_ROOT, '../docutils/writers/html5_polyglot/')):
+        if (TEST_ROOT / '../docutils/writers/html5_polyglot/').is_dir():
             self.assertIn('docutils/writers/html5_polyglot/minimal.css', styles)
         self.assertIn(f'href="{ham_css}"', styles)
 
@@ -149,7 +148,7 @@
         mys = {'_disable_config': True,
                'embed_stylesheet': True,
                'stylesheet_dirs': (
-                   os.path.join(TEST_ROOT, '../docutils/writers/html5_polyglot/'),
+                   TEST_ROOT / '../docutils/writers/html5_polyglot/',
                    DATA_ROOT),
                'stylesheet_path': 'ham.css'}
         styles = core.publish_parts(self.data, writer_name='html5_polyglot',
@@ -168,9 +167,9 @@
                                 settings_overrides=my_settings)
 
 
-minimal_css = relpath(TEST_ROOT, 'functional/input/data/minimal.css')
-plain_css = relpath(TEST_ROOT, 'functional/input/data/plain.css')
-math_css = relpath(TEST_ROOT, 'functional/input/data/math.css')
+minimal_css = relpath(TEST_ROOT / 'functional/input/data/minimal.css')
+plain_css = relpath(TEST_ROOT / 'functional/input/data/plain.css')
+math_css = relpath(TEST_ROOT / 'functional/input/data/math.css')
 
 
 class MathTestCase(unittest.TestCase):
@@ -223,7 +222,7 @@
                'math_output': 'HTML math.css,custom/style.css',
                'stylesheet_dirs': (
                    TEST_ROOT,
-                   os.path.join(TEST_ROOT, 'functional/input/data')),
+                   TEST_ROOT / 'functional/input/data'),
                'embed_stylesheet': False}
         styles = core.publish_parts(self.data, writer_name='html5_polyglot',
                                     settings_overrides=mys)['stylesheet']


Property changes on: trunk/docutils/test/test_writers/test_html5_polyglot_misc.py
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Modified: trunk/docutils/test/test_writers/test_html5_template.py
===================================================================
--- trunk/docutils/test/test_writers/test_html5_template.py	2024-06-07 12:48:23 UTC (rev 9747)
+++ trunk/docutils/test/test_writers/test_html5_template.py	2024-06-08 08:08:37 UTC (rev 9748)
@@ -23,7 +23,7 @@
 from docutils.core import publish_string
 
 # TEST_ROOT is ./test/ from the docutils root
-TEST_ROOT = os.path.abspath(os.path.join(__file__, '..', '..'))
+TEST_ROOT = Path(__file__).parents[1]
 
 
 class WriterPublishTestCase(unittest.TestCase):
@@ -30,7 +30,7 @@
     # maxDiff = None
     def test_publish(self):
         writer_name = 'html5'
-        template_path = os.path.join(TEST_ROOT, 'data', 'full-template.txt')
+        template_path = TEST_ROOT / 'data/full-template.txt'
         for name, cases in totest.items():
             for casenum, (case_input, case_expected) in enumerate(cases):
                 with self.subTest(id=f'totest[{name!r}][{casenum}]'):


Property changes on: trunk/docutils/test/test_writers/test_html5_template.py
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Modified: trunk/docutils/test/test_writers/test_manpage.py
===================================================================
--- trunk/docutils/test/test_writers/test_manpage.py	2024-06-07 12:48:23 UTC (rev 9747)
+++ trunk/docutils/test/test_writers/test_manpage.py	2024-06-08 08:08:37 UTC (rev 9748)
@@ -38,6 +38,7 @@
                         }).decode()
                     self.assertEqual(case_expected, output)
 
+
 document_start = r""".\" Man page generated from reStructuredText by manpage writer
 .\" from docutils 0.22b.dev.
 .


Property changes on: trunk/docutils/test/test_writers/test_manpage.py
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
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.