Skip to content

Commit 71d22b5

Browse files
mitya57NGC2023
andcommitted
Make the tests pass with Sphinx 7.x and 8.x
Fixes #43. Co-authored-by: Yogeswaran Umasankar <[email protected]>
1 parent 1f55a88 commit 71d22b5

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ testing = [
3434
"pytest",
3535
"pytest-regressions",
3636
"pytest-cov",
37-
"sphinx>=4.0.0,<7",
37+
"sphinx>=4.0.0,<9",
3838
]
3939
docs = [
4040
"sphinx>=4.0.0",

tests/test_render.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,13 @@
1212
from autodoc2.render.rst_ import RstRenderer
1313
from autodoc2.utils import yield_modules
1414
import pytest
15+
import sphinx
1516
from sphinx.testing.util import SphinxTestApp
16-
from sphinx.testing.util import path as sphinx_path
17+
18+
if sphinx.version_info >= (7, 2):
19+
sphinx_path = Path
20+
else:
21+
from sphinx.testing.path import path as sphinx_path
1722

1823

1924
@pytest.mark.parametrize(
@@ -224,6 +229,25 @@ def test_sphinx_build_directives(tmp_path: Path, file_regression):
224229
doctree = app.env.get_doctree("index")
225230
doctree["source"] = "index.rst"
226231
content = "\n".join([line.rstrip() for line in doctree.pformat().splitlines()])
232+
if sphinx.version_info < (7, 1):
233+
content = content.replace(
234+
'<document source="index.rst">',
235+
"<document source=\"index.rst\" translation_progress=\"{'total': 0, 'translated': 0}\">",
236+
)
237+
content = content.replace(
238+
'<desc_parameterlist xml:space="preserve">',
239+
'<desc_parameterlist multi_line_parameter_list="False" xml:space="preserve">',
240+
)
241+
if sphinx.version_info < (7, 2):
242+
content = content.replace(
243+
'<desc classes="py function" desctype="function" domain="py"',
244+
'<desc classes="py function" desctype="function" domain="py" no-contents-entry="False" no-index="False" no-index-entry="False" no-typesetting="False"',
245+
)
246+
if sphinx.version_info < (8, 2):
247+
content = content.replace(
248+
'<desc_parameterlist multi_line_parameter_list="False"',
249+
'<desc_parameterlist multi_line_parameter_list="False" multi_line_trailing_comma="True"',
250+
)
227251
file_regression.check(content, extension=".xml")
228252

229253

tests/test_render/test_sphinx_build_directives.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<document source="index.rst">
1+
<document source="index.rst" translation_progress="{'total': 0, 'translated': 0}">
22
<section ids="test" names="test">
33
<title>
44
Test
@@ -19,13 +19,13 @@
1919
```
2020
````
2121
<index entries="('single',\ 'func()\ (in\ module\ package)',\ 'package.func',\ '',\ None)">
22-
<desc classes="py function" desctype="function" domain="py" nocontentsentry="False" noindex="False" noindexentry="False" objtype="function">
22+
<desc classes="py function" desctype="function" domain="py" no-contents-entry="False" no-index="False" no-index-entry="False" no-typesetting="False" nocontentsentry="False" noindex="False" noindexentry="False" objtype="function">
2323
<desc_signature _toc_name="func()" _toc_parts="('package', 'func')" class="" classes="sig sig-object" fullname="func" ids="package.func" module="package">
2424
<desc_addname classes="sig-prename descclassname" xml:space="preserve">
2525
package.
2626
<desc_name classes="sig-name descname" xml:space="preserve">
2727
func
28-
<desc_parameterlist xml:space="preserve">
28+
<desc_parameterlist multi_line_parameter_list="False" multi_line_trailing_comma="True" xml:space="preserve">
2929
<desc_parameter xml:space="preserve">
3030
<desc_sig_name classes="n">
3131
a

0 commit comments

Comments
 (0)