Skip to content

Commit

Permalink
test: fix Sphinx 7
Browse files Browse the repository at this point in the history
  • Loading branch information
agoose77 committed Oct 29, 2023
1 parent d0675a0 commit 820ebb2
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tests/test_sphinx.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import pytest
from sphinx.testing.path import path as sphinx_path
from sphinx.testing.util import SphinxTestApp
from sphinx import version_info as sphinx_version_info

from sphinx_external_toc.tools import create_site_from_toc

Expand Down Expand Up @@ -47,7 +48,16 @@ def outdir(self):
@pytest.fixture()
def sphinx_build_factory(make_app):
def _func(src_path: Path, **kwargs) -> SphinxBuild:
app = make_app(srcdir=sphinx_path(os.path.abspath(str(src_path))), **kwargs)
# For compatibility with multiple versions of sphinx, convert pathlib.Path to
# sphinx.testing.path.path here.
if sphinx_version_info >= (7, 2):
app_srcdir = src_path
else:
from sphinx.testing.path import path

app_srcdir = path(os.fspath(src_path))

app = make_app(srcdir=app_srcdir, **kwargs)
return SphinxBuild(app, src_path)

yield _func
Expand Down

0 comments on commit 820ebb2

Please sign in to comment.