Skip to content

Commit 620ce83

Browse files
committed
Fix compatibility with Sphinx 7.2.x
sphinx-doc/sphinx#11605 Signed-off-by: Stephen Finucane <[email protected]>
1 parent dcaaf56 commit 620ce83

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

tests/conftest.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
1+
import pathlib
12
import shutil
23

4+
import sphinx
35
import pytest
4-
from sphinx.testing import path
56

67
# this is necessary because Sphinx isn't exposing its fixtures
78
# https://docs.pytest.org/en/7.1.x/how-to/writing_plugins.html#requiring-loading-plugins-in-a-test-module-or-conftest-file
89
pytest_plugins = ['sphinx.testing.fixtures']
910

1011

12+
# TODO: Remove when we no longer care about Sphinx < 7.2
1113
@pytest.fixture
1214
def rootdir(tmpdir):
13-
src = path.path(__file__).parent.abspath() / 'roots'
14-
dst = tmpdir.join('roots')
15-
shutil.copytree(src, dst)
16-
roots = path.path(dst)
17-
print(dst)
15+
if sphinx.version_info >= (7, 2, 0):
16+
src = pathlib.Path(__file__).parent.absolute().joinpath('roots')
17+
dst = tmpdir.join('roots')
18+
shutil.copytree(src, dst)
19+
roots = pathlib.Path(dst)
20+
else:
21+
from sphinx.testing import path
22+
23+
src = path.path(__file__).parent.abspath() / 'roots'
24+
dst = tmpdir.join('roots')
25+
shutil.copytree(src, dst)
26+
roots = path.path(dst)
27+
1828
yield roots
1929
shutil.rmtree(dst)

0 commit comments

Comments
 (0)