Skip to content

Commit

Permalink
[reafctor] Treat as local plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
ftnext committed Aug 5, 2024
1 parent 9110968 commit 857b426
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 28 deletions.
26 changes: 26 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import shutil
from pathlib import Path

import pytest
from bs4 import BeautifulSoup

pytest_plugins = "sphinx.testing.fixtures"
collect_ignore = ["roots"]
Expand All @@ -9,3 +11,27 @@
@pytest.fixture(scope="session")
def rootdir() -> Path:
return Path(__file__).parent / "roots"


@pytest.fixture
def parsed_built_html(
request,
make_app,
sphinx_test_tempdir: Path,
rootdir: Path,
):
marker = request.node.get_closest_marker("sphinx_build_in_tempdir")
if marker is None:
raise RuntimeError("Mark as `sphinx_build_in_tempdir`")
directory_name = marker.args[0]

srcdir = sphinx_test_tempdir / directory_name
if not srcdir.exists():
testroot_path = rootdir / f"test-{directory_name}"
shutil.copytree(testroot_path, srcdir)

app = make_app("html", srcdir=srcdir)
app.build()

html = (app.outdir / "index.html").read_text()
return BeautifulSoup(html, "html.parser")
28 changes: 0 additions & 28 deletions tests/test_show_external_link_icon.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,4 @@
import shutil
from pathlib import Path

import pytest
from bs4 import BeautifulSoup


@pytest.fixture
def parsed_built_html(
request,
make_app,
sphinx_test_tempdir: Path,
rootdir: Path,
):
marker = request.node.get_closest_marker("sphinx_build_in_tempdir")
if marker is None:
raise RuntimeError("Mark as `sphinx_build_in_tempdir`")
directory_name = marker.args[0]

srcdir = sphinx_test_tempdir / directory_name
if not srcdir.exists():
testroot_path = rootdir / f"test-{directory_name}"
shutil.copytree(testroot_path, srcdir)

app = make_app("html", srcdir=srcdir)
app.build()

html = (app.outdir / "index.html").read_text()
return BeautifulSoup(html, "html.parser")


def assert_is_external(reference, expected_url: str) -> None:
Expand Down

0 comments on commit 857b426

Please sign in to comment.