diff --git a/pyproject.toml b/pyproject.toml index 0a7881b..120a884 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -81,6 +81,7 @@ reportUnknownArgumentType = false reportUnknownMemberType = false reportUnknownParameterType = false reportUnknownVariableType = false +reportUntypedFunctionDecorator = false reportUnusedClass = true reportUnusedFunction = true reportUnusedImport = true diff --git a/setup.cfg b/setup.cfg index 65fafb3..c5172c4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -50,6 +50,7 @@ packages = find: [options.extras_require] test = + importlib-metadata; python_version <"3.8.0" pyquery # for checking HTML output pytest pytest-cov diff --git a/tests/conftest.py b/tests/conftest.py index 62c0662..c504c48 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,11 +1,28 @@ -# cspell:ignore rootdir +import sys + import pytest -from sphinx.testing.path import path + +if sys.version_info < (3, 8): + from importlib_metadata import version +else: + from importlib.metadata import version pytest_plugins = "sphinx.testing.fixtures" collect_ignore = ["roots"] -@pytest.fixture(scope="session") -def rootdir() -> path: - return path(__file__).parent.abspath() / "roots" +# cspell:ignore rootdir +sphinx_version = version("Sphinx") +if sphinx_version < "7.2": + from sphinx.testing.path import path + + @pytest.fixture(scope="session") + def rootdir() -> path: + return path(__file__).parent.abspath() / "roots" + +else: + from pathlib import Path + + @pytest.fixture(scope="session") + def rootdir() -> Path: + return Path(__file__).parent.absolute() / "roots"