Skip to content

Commit

Permalink
[refactor] Pass builder via marker
Browse files Browse the repository at this point in the history
  • Loading branch information
ftnext committed Aug 6, 2024
1 parent 52fad7d commit 4cd8bec
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ check_flake8 = "flake8 src tests"
check_mypy = "mypy src tests"

[tool.pytest.ini_options]
markers = ["sphinx_build_in_tempdir"]
markers = ["sphinx_builder", "sphinx_build_in_tempdir"]
3 changes: 2 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ def parsed_built_html(
rootdir: Path,
):
directory_name = get_marker_value(request, "sphinx_build_in_tempdir")
builder = get_marker_value(request, "sphinx_builder")

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 = make_app(builder, srcdir=srcdir)
app.build()

html = (app.outdir / "index.html").read_text()
Expand Down
3 changes: 3 additions & 0 deletions tests/test_show_external_link_icon.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ def assert_is_external(reference, expected_url: str) -> None:
assert reference["rel"] == ["noopener", "noreferrer"]


@pytest.mark.sphinx_builder("html")
@pytest.mark.sphinx_build_in_tempdir("external-link-icon")
def test_see_external_link_icon(parsed_built_html):
references = parsed_built_html.find_all("a", {"class": "reference"})
Expand All @@ -17,6 +18,7 @@ def test_see_external_link_icon(parsed_built_html):
assert_is_external(ref, "https://pypi.org/project/sphinx-new-tab-link/")


@pytest.mark.sphinx_builder("html")
@pytest.mark.sphinx_build_in_tempdir("external-link-icon")
def test_can_see_icon_with_image_directive_target(parsed_built_html):
# https://github.com/ftnext/sphinx-new-tab-link/issues/16
Expand All @@ -32,6 +34,7 @@ def test_can_see_icon_with_image_directive_target(parsed_built_html):
assert ref.svg


@pytest.mark.sphinx_builder("html")
@pytest.mark.sphinx_build_in_tempdir("external-link-icon")
def test_can_see_icon_with_figure_directive_target(parsed_built_html):
references = parsed_built_html.find_all("a", {"class": "reference"})
Expand Down

0 comments on commit 4cd8bec

Please sign in to comment.