From 30364f1a04da5a9b30f197b47cd12c26df7cb667 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Tue, 26 Sep 2023 11:21:48 -0700 Subject: [PATCH] Fix tests on sphinx 7 --- tests/conftest.py | 12 ++++++++++-- tests/test_incremental.py | 6 +++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 748f5690..b26297b0 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2,10 +2,13 @@ import sys from pathlib import Path +import sphinx + +SPHINX_VERSION = tuple(int(x) for x in sphinx.__version__.split(".")) + sys.path.append(str(Path(__file__).parent)) import pytest -from sphinx.testing.path import path if "SPHINX_JS_NODE_MODULES" not in os.environ: for p in [Path(sys.prefix), Path(__file__).parents[1]]: @@ -31,4 +34,9 @@ @pytest.fixture(scope="session") def rootdir(): - return path(__file__).parent.abspath() / "roots" + rootdir = Path(__file__).parent.resolve() / "roots" + if SPHINX_VERSION < (7, 0, 0): + from sphinx.testing.path import path + + return path(rootdir) + return rootdir diff --git a/tests/test_incremental.py b/tests/test_incremental.py index 9bce7139..b8e17348 100644 --- a/tests/test_incremental.py +++ b/tests/test_incremental.py @@ -1,10 +1,10 @@ """Test incremental builds.""" import warnings +from pathlib import Path import pytest from sphinx.environment import CONFIG_NEW, CONFIG_OK -from sphinx.testing.path import path from sphinx.testing.util import strip_escseq @@ -56,7 +56,7 @@ def do_test(app, extension="js"): assert writes == [] # Incremental build, one file changed. - a_js = path(app.srcdir) / f"a.{extension}" + a_js = Path(app.srcdir) / f"a.{extension}" a_js.write_text(a_js.read_text() + "\n\n") assert app.env.config_status == CONFIG_OK @@ -69,7 +69,7 @@ def do_test(app, extension="js"): assert writes == ["a", "a_b", "index"] # Incremental build, the other file changed. - b_js = path(app.srcdir) / "inner" / f"b.{extension}" + b_js = Path(app.srcdir) / "inner" / f"b.{extension}" b_js.write_text(b_js.read_text() + "\n\n") assert app.env.config_status == CONFIG_OK