11"""Tests for the rendering."""
22
33import io
4+ import os
45from pathlib import Path
56from textwrap import dedent
67
1213from autodoc2 .render .rst_ import RstRenderer
1314from autodoc2 .utils import yield_modules
1415import pytest
16+ import sphinx
1517from sphinx .testing .util import SphinxTestApp
16- from sphinx .testing .util import path as sphinx_path
18+
19+ if sphinx .version_info >= (7 , 2 ):
20+ sphinx_path = Path
21+ else :
22+ from sphinx .testing .path import path as sphinx_path
1723
1824
1925@pytest .mark .parametrize (
@@ -94,8 +100,8 @@ def test_sphinx_build(tmp_path: Path, with_rebuild: bool):
94100 build = tmp_path / "build"
95101 app = SphinxTestApp (
96102 buildername = "html" ,
97- srcdir = sphinx_path (source ),
98- builddir = sphinx_path (build ),
103+ srcdir = sphinx_path (os . path . abspath ( source ) ),
104+ builddir = sphinx_path (os . path . abspath ( build ) ),
99105 warning = warnings ,
100106 )
101107 try :
@@ -137,8 +143,8 @@ def test_sphinx_build(tmp_path: Path, with_rebuild: bool):
137143 rebuild_warnings = io .StringIO ()
138144 rebuild_app = SphinxTestApp (
139145 buildername = "html" ,
140- srcdir = sphinx_path (source ),
141- builddir = sphinx_path (build ),
146+ srcdir = sphinx_path (os . path . abspath ( source ) ),
147+ builddir = sphinx_path (os . path . abspath ( build ) ),
142148 warning = rebuild_warnings ,
143149 )
144150 try :
@@ -210,8 +216,8 @@ def test_sphinx_build_directives(tmp_path: Path, file_regression):
210216 build = tmp_path / "build"
211217 app = SphinxTestApp (
212218 buildername = "html" ,
213- srcdir = sphinx_path (source ),
214- builddir = sphinx_path (build ),
219+ srcdir = sphinx_path (os . path . abspath ( source ) ),
220+ builddir = sphinx_path (os . path . abspath ( build ) ),
215221 warning = warnings ,
216222 )
217223 try :
@@ -224,6 +230,25 @@ def test_sphinx_build_directives(tmp_path: Path, file_regression):
224230 doctree = app .env .get_doctree ("index" )
225231 doctree ["source" ] = "index.rst"
226232 content = "\n " .join ([line .rstrip () for line in doctree .pformat ().splitlines ()])
233+ if sphinx .version_info < (7 , 1 ):
234+ content = content .replace (
235+ '<document source="index.rst">' ,
236+ "<document source=\" index.rst\" translation_progress=\" {'total': 0, 'translated': 0}\" >" ,
237+ )
238+ content = content .replace (
239+ '<desc_parameterlist xml:space="preserve">' ,
240+ '<desc_parameterlist multi_line_parameter_list="False" xml:space="preserve">' ,
241+ )
242+ if sphinx .version_info < (7 , 2 ):
243+ content = content .replace (
244+ '<desc classes="py function" desctype="function" domain="py"' ,
245+ '<desc classes="py function" desctype="function" domain="py" no-contents-entry="False" no-index="False" no-index-entry="False" no-typesetting="False"' ,
246+ )
247+ if sphinx .version_info < (8 , 2 ):
248+ content = content .replace (
249+ '<desc_parameterlist multi_line_parameter_list="False"' ,
250+ '<desc_parameterlist multi_line_parameter_list="False" multi_line_trailing_comma="True"' ,
251+ )
227252 file_regression .check (content , extension = ".xml" )
228253
229254
0 commit comments