-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sphinx-doc/sphinx#11605 Signed-off-by: Stephen Finucane <[email protected]>
- Loading branch information
1 parent
dcaaf56
commit 620ce83
Showing
1 changed file
with
16 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,29 @@ | ||
import pathlib | ||
import shutil | ||
|
||
import sphinx | ||
import pytest | ||
from sphinx.testing import path | ||
|
||
# this is necessary because Sphinx isn't exposing its fixtures | ||
# https://docs.pytest.org/en/7.1.x/how-to/writing_plugins.html#requiring-loading-plugins-in-a-test-module-or-conftest-file | ||
pytest_plugins = ['sphinx.testing.fixtures'] | ||
|
||
|
||
# TODO: Remove when we no longer care about Sphinx < 7.2 | ||
@pytest.fixture | ||
def rootdir(tmpdir): | ||
src = path.path(__file__).parent.abspath() / 'roots' | ||
dst = tmpdir.join('roots') | ||
shutil.copytree(src, dst) | ||
roots = path.path(dst) | ||
print(dst) | ||
if sphinx.version_info >= (7, 2, 0): | ||
src = pathlib.Path(__file__).parent.absolute().joinpath('roots') | ||
dst = tmpdir.join('roots') | ||
shutil.copytree(src, dst) | ||
roots = pathlib.Path(dst) | ||
else: | ||
from sphinx.testing import path | ||
|
||
src = path.path(__file__).parent.abspath() / 'roots' | ||
dst = tmpdir.join('roots') | ||
shutil.copytree(src, dst) | ||
roots = path.path(dst) | ||
|
||
yield roots | ||
shutil.rmtree(dst) |