Skip to content

Commit

Permalink
Fix Trait documenter tests for Sphinx >= 7.2 (#1755)
Browse files Browse the repository at this point in the history
This PR fixes the Trait documenter test for Sphinx >= 7.2. For that
version of Sphinx, the `srcdir` argument to `SphinxTestApp` needs to be
a `pathlib.Path` object rather than a `sphinx.testing.path.path` object.

Closes #1754
  • Loading branch information
mdickinson committed Sep 11, 2023
1 parent d066c6d commit f644cc2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions traits/util/tests/test_trait_documenter.py
Expand Up @@ -27,7 +27,6 @@
if sphinx is not None:
from sphinx.ext.autodoc import ClassDocumenter, INSTANCEATTR, Options
from sphinx.ext.autodoc.directive import DocumenterBridge
from sphinx.testing.path import path
from sphinx.testing.util import SphinxTestApp
from sphinx.util.docutils import LoggingReporter

Expand All @@ -37,6 +36,11 @@
TraitDocumenter,
)

if sphinx.version_info < (7, 2):
from sphinx.testing.path import path as Path
else:
from pathlib import Path


# Configuration file content for testing.
CONF_PY = """\
Expand Down Expand Up @@ -223,7 +227,7 @@ def create_directive(self):
with open(conf_file, "w", encoding="utf-8") as f:
f.write(CONF_PY)

app = SphinxTestApp(srcdir=path(tmpdir))
app = SphinxTestApp(srcdir=Path(tmpdir))
app.builder.env.app = app
app.builder.env.temp_data["docname"] = "dummy"

Expand Down

0 comments on commit f644cc2

Please sign in to comment.