diff --git a/src/byteb4rb1e/sphinxcontrib/testing/pytest/fixtures.py b/src/byteb4rb1e/sphinxcontrib/testing/pytest/fixtures.py index 6fc4416..dbee461 100644 --- a/src/byteb4rb1e/sphinxcontrib/testing/pytest/fixtures.py +++ b/src/byteb4rb1e/sphinxcontrib/testing/pytest/fixtures.py @@ -5,10 +5,25 @@ import os from pathlib import Path import shutil from typing import Any, Tuple, Callable, Iterator, Dict +import warnings import pytest + +try: + from sphinx.deprecation import RemovedInSphinx90Warning +except ImportError: + RemovedInSphinx90Warning = None + from sphinx.testing.util import SphinxTestApp from sphinx.testing.fixtures import make_app, test_params +USE_PATHLIB = True +with warnings.catch_warnings(record=True) as w: + warnings.simplefilter('always') + from sphinx.testing.path import path as sphinxtesting_path + if w and issubclass(w[-1].message.__class__, RemovedInSphinx90Warning): + USE_PATHLIB = True + else: + USE_PATHLIB = False from byteb4rb1e.testing.pytest.fixtures import current_test @@ -75,9 +90,10 @@ def mock_sphinx_testapp( builddir = basedir / 'build' shutil.copytree(kwargs['srcdir'], srcdir, dirs_exist_ok=True) - kwargs['srcdir'] = srcdir - kwargs.setdefault('builddir', builddir) + kwargs['srcdir'] = sphinxtesting_path(srcdir) if not USE_PATHLIB else srcdir + + kwargs.setdefault('builddir', sphinxtesting_path(builddir) if not USE_PATHLIB else builddir) app_ = make_app(*args, **kwargs) diff --git a/tests/integration/byteb4rb1e/sphinxcontrib/testing/pytest/test_fixtures.py b/tests/integration/byteb4rb1e/sphinxcontrib/testing/pytest/test_fixtures.py index 3369ee6..9d66cde 100644 --- a/tests/integration/byteb4rb1e/sphinxcontrib/testing/pytest/test_fixtures.py +++ b/tests/integration/byteb4rb1e/sphinxcontrib/testing/pytest/test_fixtures.py @@ -1,3 +1,4 @@ +from pathlib import Path import pytest @@ -26,6 +27,6 @@ def test_mock_sphinx_testapp(mock_sphinx_testapp, mock_sphinx_testsrc_dir): app = mock_sphinx_testapp(srcdir=srcdir) assert app.builder is not None - assert app.srcdir.samefile(srcdir) is False # Should be copied to internal src + assert Path(app.srcdir).samefile(srcdir) is False # Should be copied to internal src app.build(force_all=True)