def test_autodoc(app, warning): app.build() assert not warning.getvalue() output = (app.outdir / "doc_cite.html").read_text() labels = [ 'One', 'Two', 'Thr', 'Fou', 'Fiv', 'Six', 'Sev', 'Eig', 'Nin', 'Ten', 'Ele' ] titles = [ 'Een', 'Twee', 'Drie', 'Vier', 'Vijf', 'Zes', 'Zeven', 'Acht', 'Negen', 'Tien', 'Elf' ] for label, title in zip(labels, titles): assert len(common.html_citation_refs(label=label).findall(output)) == 1 assert len(common.html_citations(label=label).findall(output)) == 1 match_ref = common.html_citation_refs(label=label).search(output) match = common.html_citations(label=label).search(output) assert match_ref assert match assert match_ref.group('refid') == match.group('id_') assert title in match.group('text') output2 = (app.outdir / "doc_footcite.html").read_text() assert len(common.html_footnote_refs().findall(output2)) == 11 for title in titles: text = ".*" + title + ".*" assert len(common.html_footnotes(text=text).findall(output2)) == 1 match = common.html_footnotes(text=text).search(output2) assert match id_ = match.group('id_') assert len(common.html_footnote_refs(refid=id_).findall(output2)) == 1
def test_citation_whitespace(app, warning): app.build() assert not warning.getvalue() output = (app.outdir / "index.html").read_text() # ensure Man09 is cited assert len(common.html_citation_refs(label='Fir').findall(output)) == 1 assert len(common.html_citation_refs(label='Sec').findall(output)) == 1
def test_bibliography_style_label_1(app, warning): app.build() assert not warning.getvalue() output = (app.outdir / "index.html").read_text() # the custom style uses keys as labels # citations assert len(common.html_citations( label='myfancybibtexkey').findall(output)) == 1 assert len(common.html_citations( label='myotherfancybibtexkey').findall(output)) == 1 assert len(common.html_citation_refs( label='myfancybibtexkey').findall(output)) == 1 assert len(common.html_citation_refs( label='myotherfancybibtexkey').findall(output)) == 1
def test_bibliography_label_prefix_2(app, warning): doc1_refs = {'AFM12', 'ABlu83', 'AGIH02', 'AWS14'} doc1_cites = {'ABlu83', 'AFM12', 'AGIH02', 'AWS14'} doc2_refs = {'BShi13'} doc2_cites = {'BShi13'} sum_refs = {'CMcMahonKM10', 'CRMM11', 'CRM09', 'CMM03', 'CHdJMD13', 'AFM12'} sum_cites = {'CMcMahonKM10', 'CRMM11', 'CRM09', 'CMM03', 'CHdJMD13'} app.build() assert not warning.getvalue() output1 = (app.outdir / "doc1.html").read_text() assert doc1_refs == citation_refs(output1) assert doc1_cites == citations(output1) output2 = (app.outdir / "doc2.html").read_text() assert doc2_refs == citation_refs(output2) assert doc2_cites == citations(output2) output3 = (app.outdir / "summary.html").read_text() assert sum_refs == citation_refs(output3) assert sum_cites == citations(output3) # check citation reference from summary to doc1 match1 = common.html_citations(label='AFM12').search(output1) match3 = common.html_citation_refs(label='AFM12').search(output3) assert match1 assert match3 assert match1.group('id_') == match3.group('refid') assert match3.group('refdoc') == 'doc1.html'
def test_duplicate_nearly_identical_entries(app, warning): app.build() assert not warning.getvalue() output = (app.outdir / "index.html").read_text() cits = list(common.html_citations().finditer(output)) cit_refs = list(common.html_citation_refs().finditer(output)) assert len(cits) == len(cit_refs) == 2 assert ({cit.group('label') for cit in cits} == {cit_ref.group('label') for cit_ref in cit_refs} == {'xyz19a', 'xyz19b'})
def test_citation_multiple_keys(app, warning): app.build() assert not warning.getvalue() output = (app.outdir / "index.html").read_text() cits = { match.group('label') for match in common.html_citations().finditer(output) } citrefs = { match.group('label') for match in common.html_citation_refs().finditer(output) } assert {"App", "Bra"} == cits == citrefs
def test_duplicate_nearly_identical_keys(app, warning): app.build() assert not warning.getvalue() output = (app.outdir / "index.html").read_text() # assure both citations and citation references are present assert common.html_citation_refs(label='Smi').search(output) assert common.html_citation_refs(label='Pop').search(output) assert common.html_citation_refs(label='Ein').search(output) assert common.html_citations(label='Smi').search(output) assert common.html_citations(label='Pop').search(output) assert common.html_citations(label='Ein').search(output) # assure distinct ids for citations ids = { match.group('id_') for match in common.html_citations().finditer(output) } refids = { match.group('refid') for match in common.html_citation_refs().finditer(output) } assert None not in ids assert len(ids) == 3 assert ids == refids
def test_duplicate_citation_id(app, warning): app.build() assert not warning.getvalue() output = (app.outdir / "index.html").read_text() user_ids = {'id1', 'id2', 'id3'} ids = { match.group('id_') for match in common.html_citations().finditer(output) } refids = { match.group('refid') for match in common.html_citation_refs().finditer(output) } assert ids == refids assert len(ids) == 1 assert not (user_ids & ids)
def test_bibliography_style_label_2(app, warning): app.build() assert not warning.getvalue() output = (app.outdir / "index.html").read_text() assert len(common.html_citation_refs(label='APAa').findall(output)) == 1 assert len(common.html_citation_refs(label='APAb').findall(output)) == 1
def citation_refs(output): return {match.group('label') for match in common.html_citation_refs().finditer(output)}