Skip to content

Commit

Permalink
Fix tests on sphinx 7
Browse files Browse the repository at this point in the history
  • Loading branch information
hoodmane committed Sep 26, 2023
1 parent 41991b2 commit 30364f1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
12 changes: 10 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]]:
Expand All @@ -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
6 changes: 3 additions & 3 deletions tests/test_incremental.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 30364f1

Please sign in to comment.