Skip to content

Commit

Permalink
FIX: import sphinx.testing.path for lower Sphinx versions
Browse files Browse the repository at this point in the history
  • Loading branch information
redeboer committed Sep 28, 2023
1 parent 0256d07 commit 2be6cce
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ reportUnknownArgumentType = false
reportUnknownMemberType = false
reportUnknownParameterType = false
reportUnknownVariableType = false
reportUntypedFunctionDecorator = false
reportUnusedClass = true
reportUnusedFunction = true
reportUnusedImport = true
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 22 additions & 5 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 2be6cce

Please sign in to comment.