Skip to content

Commit

Permalink
tests: fix varioun versions of sphinx
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
  • Loading branch information
henryiii committed May 22, 2024
1 parent 9ce924f commit 9a678ab
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
3 changes: 1 addition & 2 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,5 @@ def tests(session):
"""
Run the unit and regular tests.
"""
# Setuptools is required due to sphinx installing sphinxcontrib extensions that use pkg_resources (fixed upstream but not released yet)
session.install(".", "pytest", "setuptools")
session.install(".[test]", silent=False)
session.run("pytest", *session.posargs)
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ dynamic = ["version"]
Homepage = "https://github.com/scikit-build/moderncmakedomain"

[project.optional-dependencies]
test = ["pytest"]
test = [
# Setuptools is required due to sphinx installing sphinxcontrib extensions that use pkg_resources (fixed upstream but not released yet)
"pytest",
"defusedxml",
]

[tool.pytest.ini_options]
minversion = "6.0"
Expand Down
24 changes: 20 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
import pytest

from pathlib import Path
import sys

if sys.version_info < (3, 8):
from importlib_metadata import version
else:
from importlib.metadata import version

sphinx_vesion = tuple(int(d) for d in version("sphinx").split(".")[:2])

pytest_plugins = 'sphinx.testing.fixtures'

@pytest.fixture(scope="session")
def rootdir():
return Path(__file__).parent.absolute() / "roots"
if sphinx_vesion < (7, 3):
from sphinx.testing.path import path

@pytest.fixture(scope="session")
def rootdir():
return path(__file__).parent.abspath() / "roots"
else:
from pathlib import Path

@pytest.fixture(scope="session")
def rootdir():
return Path(__file__).parent.absolute() / "roots"

0 comments on commit 9a678ab

Please sign in to comment.