1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
|
Description: Fix for test_render
Fix for path and AssertionError in test_render, revised xml file
for the updated sphinx.
Forwarded: https://github.com/sphinx-extensions2/sphinx-autodoc2/pull/91
Author: Yogeswaran Umasankar <kd8mbd@gmail.com>
Last-Update: 2025-11-09
--- a/tests/test_render.py
+++ b/tests/test_render.py
@@ -1,5 +1,6 @@
"""Tests for the rendering."""
import io
+import os
from pathlib import Path
from textwrap import dedent
@@ -10,10 +11,10 @@ from autodoc2.render.base import Rendere
from autodoc2.render.myst_ import MystRenderer
from autodoc2.render.rst_ import RstRenderer
from autodoc2.utils import yield_modules
+import docutils
import pytest
+import sphinx
from sphinx.testing.util import SphinxTestApp
-from sphinx.testing.util import path as sphinx_path
-
@pytest.mark.parametrize(
"renderer,extension",
@@ -93,8 +94,8 @@ def test_sphinx_build(tmp_path: Path, wi
build = tmp_path / "build"
app = SphinxTestApp(
buildername="html",
- srcdir=sphinx_path(source),
- builddir=sphinx_path(build),
+ srcdir=Path(os.path.abspath(source)),
+ builddir=Path(os.path.abspath(build)),
warning=warnings,
)
try:
@@ -136,8 +137,8 @@ def test_sphinx_build(tmp_path: Path, wi
rebuild_warnings = io.StringIO()
rebuild_app = SphinxTestApp(
buildername="html",
- srcdir=sphinx_path(source),
- builddir=sphinx_path(build),
+ srcdir=Path(os.path.abspath(source)),
+ builddir=Path(os.path.abspath(build)),
warning=rebuild_warnings,
)
try:
@@ -209,8 +210,8 @@ def test_sphinx_build_directives(tmp_pat
build = tmp_path / "build"
app = SphinxTestApp(
buildername="html",
- srcdir=sphinx_path(source),
- builddir=sphinx_path(build),
+ srcdir=Path(os.path.abspath(source)),
+ builddir=Path(os.path.abspath(build)),
warning=warnings,
)
try:
@@ -223,6 +224,18 @@ def test_sphinx_build_directives(tmp_pat
doctree = app.env.get_doctree("index")
doctree["source"] = "index.rst"
content = "\n".join([line.rstrip() for line in doctree.pformat().splitlines()])
+ if sphinx.version_info < (8, 2):
+ content = content.replace(
+ '<desc_parameterlist multi_line_parameter_list="False"',
+ '<desc_parameterlist multi_line_parameter_list="False" multi_line_trailing_comma="True"',
+ )
+ if docutils.__version_info__ < (0, 22):
+ content = content.replace('="False"', '="0"')
+ content = content.replace('linenos="True"', 'linenos="1"')
+ content = content.replace(
+ 'multi_line_trailing_comma="True"', 'multi_line_trailing_comma="1"'
+ )
+ content = content.replace('refexplicit="True"', 'refexplicit="1"')
file_regression.check(content, extension=".xml")
--- a/tests/test_render/test_sphinx_build_directives.xml
+++ b/tests/test_render/test_sphinx_build_directives.xml
@@ -1,8 +1,8 @@
-<document source="index.rst">
+<document source="index.rst" translation_progress="{'total': 0, 'translated': 0}">
<section ids="test" names="test">
<title>
Test
- <literal_block highlight_args="{'linenostart': 9}" language="restructuredtext" linenos="True" xml:space="preserve">
+ <literal_block highlight_args="{'linenostart': 9}" language="restructuredtext" linenos="1" xml:space="preserve">
This is a function.
<paragraph>
This is a function.
@@ -19,13 +19,13 @@
```
````
<index entries="('single',\ 'func()\ (in\ module\ package)',\ 'package.func',\ '',\ None)">
- <desc classes="py function" desctype="function" domain="py" nocontentsentry="False" noindex="False" noindexentry="False" objtype="function">
+ <desc classes="py function" desctype="function" domain="py" no-contents-entry="0" no-index="0" no-index-entry="0" no-typesetting="0" nocontentsentry="0" noindex="0" noindexentry="0" objtype="function">
<desc_signature _toc_name="func()" _toc_parts="('package', 'func')" class="" classes="sig sig-object" fullname="func" ids="package.func" module="package">
<desc_addname classes="sig-prename descclassname" xml:space="preserve">
package.
<desc_name classes="sig-name descname" xml:space="preserve">
func
- <desc_parameterlist xml:space="preserve">
+ <desc_parameterlist multi_line_parameter_list="0" multi_line_trailing_comma="1" xml:space="preserve">
<desc_parameter xml:space="preserve">
<desc_sig_name classes="n">
a
@@ -34,7 +34,7 @@
<desc_sig_space classes="w">
<desc_sig_name classes="n">
- <pending_xref py:class="True" py:module="package" refdomain="py" refspecific="False" reftarget="str" reftype="class">
+ <pending_xref py:class="True" py:module="package" refdomain="py" refspecific="0" reftarget="str" reftype="class">
str
<desc_parameter xml:space="preserve">
<desc_sig_name classes="n">
@@ -44,10 +44,10 @@
<desc_sig_space classes="w">
<desc_sig_name classes="n">
- <pending_xref py:class="True" py:module="package" refdomain="py" refspecific="False" reftarget="int" reftype="class">
+ <pending_xref py:class="True" py:module="package" refdomain="py" refspecific="0" reftarget="int" reftype="class">
int
<desc_returns xml:space="preserve">
- <pending_xref py:class="True" py:module="package" refdomain="py" refspecific="False" reftarget="package.a.c.ac1" reftype="class">
+ <pending_xref py:class="True" py:module="package" refdomain="py" refspecific="0" reftarget="package.a.c.ac1" reftype="class">
package.a.c.ac1
<desc_content>
<paragraph>
@@ -60,7 +60,7 @@
<row>
<entry>
<paragraph>
- <pending_xref py:class="True" py:module="True" refdoc="index" refdomain="py" refexplicit="False" reftarget="package.func" reftype="obj" refwarn="False">
+ <pending_xref py:class="True" py:module="True" refdoc="index" refdomain="py" refexplicit="0" reftarget="package.func" reftype="obj" refwarn="0">
<literal classes="xref py py-obj">
package.func
<entry>
@@ -69,7 +69,7 @@
<row>
<entry>
<paragraph>
- <pending_xref py:class="True" py:module="True" refdoc="index" refdomain="py" refexplicit="True" reftarget="package.a.a1" reftype="obj" refwarn="False">
+ <pending_xref py:class="True" py:module="True" refdoc="index" refdomain="py" refexplicit="1" reftarget="package.a.a1" reftype="obj" refwarn="0">
<literal classes="xref py py-obj">
package.a1
<entry>
|