SF.net SVN: docutils:[9855 ] trunk/docutils/test/test _writers/test_html5_polyglo t_parts.py

milde--- via Docutils-checkins <[email protected]>
Newsgroups gmane.text.docutils.cvs
Message-ID <[email protected]>
Revision: 9855
          http://sourceforge.net/p/docutils/code/9855
Author:   milde
Date:     2024-08-06 08:02:23 +0000 (Tue, 06 Aug 2024)
Log Message:
-----------
Fix test script failure if run from a sub-dir of docutils/test/.

Commit [r9785] utilizes `pathlib.Path.relative_to()` in
file-path normalization.
This method fails if there is no common part in the two paths,
e.g., when running "test/test_writers/test_html5_polyglot_parts.py"
stand-alone or the test suite from "test/test_writers/".

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

Modified: trunk/docutils/test/test_writers/test_html5_polyglot_parts.py
===================================================================
--- trunk/docutils/test/test_writers/test_html5_polyglot_parts.py	2024-08-06 08:02:06 UTC (rev 9854)
+++ trunk/docutils/test/test_writers/test_html5_polyglot_parts.py	2024-08-06 08:02:23 UTC (rev 9855)
@@ -36,7 +36,7 @@
 
 # TEST_ROOT is ./test/ from the docutils root
 TEST_ROOT = Path(__file__).parents[1]
-DATA_ROOT = TEST_ROOT / 'data'
+DATA_ROOT = (TEST_ROOT / 'data').as_posix()
 ROOT_PREFIX = (TEST_ROOT / 'functional/input').as_posix()
 
 # Pillow/PIL is optional:
@@ -66,10 +66,6 @@
         '</aside>\n')
 
 
-def relpath(path: Path) -> str:
-    return path.relative_to(Path.cwd()).as_posix()
-
-
 class Html5WriterPublishPartsTestCase(unittest.TestCase):
     """Test case for HTML writer via the publish_parts interface."""
 
@@ -546,7 +542,7 @@
 """,
 }],
 [f"""\
-.. include:: {relpath(DATA_ROOT / 'multiple-term-definition.xml')}
+.. include:: {DATA_ROOT}/multiple-term-definition.xml
    :parser: xml
 """,
 {'fragment': """\
@@ -718,7 +714,7 @@
 """,
 }],
 [f"""\
-.. image:: {relpath(DATA_ROOT / 'circle-broken.svg')}
+.. image:: {DATA_ROOT}/circle-broken.svg
    :loading: embed
 """,
 {'fragment': f"""\
@@ -729,7 +725,7 @@
 
 <aside class="system-message">
 <p class="system-message-title">System Message: ERROR/3 (<span class="docutils literal">&lt;string&gt;</span>, line 1)</p>
-<p>Cannot parse SVG image &quot;{relpath(DATA_ROOT / 'circle-broken.svg')}&quot;:
+<p>Cannot parse SVG image &quot;{DATA_ROOT}/circle-broken.svg&quot;:
   not well-formed (invalid token): line 3, column 48</p>
 </aside>
 """
@@ -835,7 +831,7 @@
 """,
 }],
 [f"""\
-.. image:: {relpath(DATA_ROOT / 'circle-broken.svg')}
+.. image:: {DATA_ROOT}/circle-broken.svg
    :loading: embed
 """,
 {'fragment': """\

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.