Skip to content

Commit

Permalink
Verify output.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmtroffaes committed Feb 1, 2022
1 parent d6d79d3 commit e6b7d23
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
9 changes: 9 additions & 0 deletions test/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ def html_citation_refs(refid=RE_ID, label=RE_LABEL, title=RE_TITLE):
r'</a>'.format(refid=refid, label=label, title=title))


def html_docutils_citation_refs(refid=RE_ID, label=RE_LABEL, id_=RE_ID):
return re.compile(
r'<a class="reference internal" '
r'href="(?P<refdoc>[^#]+)?#(?P<refid>{refid})" '
r'id="(?P<id_>{id_})">'
r'<span>\[(?P<label>{label})]</span>'
r'</a>'.format(refid=refid, label=label, id_=id_))


def html_citations(id_=RE_ID, label=RE_LABEL, text=RE_TEXT):
return re.compile(
r'<dt class="label" id="(?P<id_>{id_})">'
Expand Down
13 changes: 10 additions & 3 deletions test/test_citation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from test.common import html_citations, html_citation_refs
from test.common import html_citations, html_citation_refs, \
html_docutils_citation_refs
import dataclasses
import pytest
import re
Expand Down Expand Up @@ -367,5 +368,11 @@ def test_citation_style_round_brackets(app, warning) -> None:
def test_citation_toctree(app, warning) -> None:
app.build()
assert not warning.getvalue()
output1 = (app.outdir / "index.html").read_text()
output2 = (app.outdir / "adoc1.html").read_text()
output = (app.outdir / "index.html").read_text()
output1 = (app.outdir / "adoc1.html").read_text()
output2 = (app.outdir / "adoc2.html").read_text()
assert len(html_citations(label='1').findall(output)) == 1
assert len(html_citation_refs(label='1').findall(output1)) == 1
assert len(html_docutils_citation_refs(
label=r'Test2').findall(output2)) == 1
assert len(html_citations(label='Test2').findall(output2)) == 1

0 comments on commit e6b7d23

Please sign in to comment.