Skip to content

Commit

Permalink
Fix compatibility with Sphinx 7.2.x
Browse files Browse the repository at this point in the history
sphinx-doc/sphinx#11605

Signed-off-by: Stephen Finucane <stephen@that.guru>
  • Loading branch information
stephenfin committed Aug 17, 2023
1 parent dcaaf56 commit 620ce83
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions tests/conftest.py
@@ -1,19 +1,29 @@
import pathlib
import shutil

import sphinx
import pytest
from sphinx.testing import path

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


# TODO: Remove when we no longer care about Sphinx < 7.2
@pytest.fixture
def rootdir(tmpdir):
src = path.path(__file__).parent.abspath() / 'roots'
dst = tmpdir.join('roots')
shutil.copytree(src, dst)
roots = path.path(dst)
print(dst)
if sphinx.version_info >= (7, 2, 0):
src = pathlib.Path(__file__).parent.absolute().joinpath('roots')
dst = tmpdir.join('roots')
shutil.copytree(src, dst)
roots = pathlib.Path(dst)
else:
from sphinx.testing import path

src = path.path(__file__).parent.abspath() / 'roots'
dst = tmpdir.join('roots')
shutil.copytree(src, dst)
roots = path.path(dst)

yield roots
shutil.rmtree(dst)

0 comments on commit 620ce83

Please sign in to comment.