Slide 71
Slide 71 text
ビルド想定のe2eテスト
sphinx.testing
を利用できる。
import pytest
from bs4 import BeautifulSoup
from bs4.element import NavigableString, Tag
from sphinx.testing.util import SphinxTestApp
@pytest.mark.sphinx("html")
def test_default(app: SphinxTestApp, status: StringIO, warning: StringIO):
app.build()
out_html = app.outdir / "index.html"
soup = BeautifulSoup(out_html.read_text(), "html.parser")
contents = list(soup.h1.children)
assert len(contents) > 1
assert isinstance(contents[0], NavigableString)
assert isinstance(contents[1], Tag)
assert contents[1].name == "wbr"