Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: fix varioun versions of sphinx #46

Merged
merged 1 commit into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Loading