def test_html_index_entries(app): app.build() # --- index entries: regression test for #976 result = (app.outdir / 'genindex.html').read_text() def wrap(tag, keyword): start_tag = "<%s[^>]*>" % tag end_tag = "</%s>" % tag return r"%s\s*%s\s*%s" % (start_tag, keyword, end_tag) def wrap_nest(parenttag, childtag, keyword): start_tag1 = "<%s[^>]*>" % parenttag start_tag2 = "<%s[^>]*>" % childtag return r"%s\s*%s\s*%s" % (start_tag1, keyword, start_tag2) expected_exprs = [ wrap('a', 'NEWSLETTER'), wrap('a', 'MAILING LIST'), wrap('a', 'RECIPIENTS LIST'), wrap('a', 'FIRST SECOND'), wrap('a', 'SECOND THIRD'), wrap('a', 'THIRD, FIRST'), wrap_nest('li', 'ul', 'ENTRY'), wrap_nest('li', 'ul', 'SEE'), wrap('a', 'MODULE'), wrap('a', 'KEYWORD'), wrap('a', 'OPERATOR'), wrap('a', 'OBJECT'), wrap('a', 'EXCEPTION'), wrap('a', 'STATEMENT'), wrap('a', 'BUILTIN'), ] for expr in expected_exprs: assert_re_search(expr, result, re.M)
def test_text_emit_warnings(app, warning): app.build() # test warnings in translation warnings = getwarning(warning) warning_expr = ('.*/warnings.txt:4:<translated>:1: ' 'WARNING: Inline literal start-string without end-string.\n') assert_re_search(warning_expr, warnings)
def test_html_index_entries(app): app.build() # --- index entries: regression test for #976 result = (app.outdir / 'genindex.html').text(encoding='utf-8') def wrap(tag, keyword): start_tag = "<%s[^>]*>" % tag end_tag = "</%s>" % tag return r"%s\s*%s\s*%s" % (start_tag, keyword, end_tag) def wrap_nest(parenttag, childtag, keyword): start_tag1 = "<%s[^>]*>" % parenttag start_tag2 = "<%s[^>]*>" % childtag return r"%s\s*%s\s*%s" % (start_tag1, keyword, start_tag2) expected_exprs = [ wrap('a', 'NEWSLETTER'), wrap('a', 'MAILING LIST'), wrap('a', 'RECIPIENTS LIST'), wrap('a', 'FIRST SECOND'), wrap('a', 'SECOND THIRD'), wrap('a', 'THIRD, FIRST'), wrap_nest('li', 'ul', 'ENTRY'), wrap_nest('li', 'ul', 'SEE'), wrap('a', 'MODULE'), wrap('a', 'KEYWORD'), wrap('a', 'OPERATOR'), wrap('a', 'OBJECT'), wrap('a', 'EXCEPTION'), wrap('a', 'STATEMENT'), wrap('a', 'BUILTIN'), ] for expr in expected_exprs: assert_re_search(expr, result, re.M)
def test_html_index_entries(app): app.build() # --- index entries: regression test for #976 result = read_text_from_sphinx_path(app.outdir / "genindex.html") def wrap(tag, keyword): start_tag = "<%s[^>]*>" % tag end_tag = "</%s>" % tag return r"%s\s*%s\s*%s" % (start_tag, keyword, end_tag) def wrap_nest(parenttag, childtag, keyword): start_tag1 = "<%s[^>]*>" % parenttag start_tag2 = "<%s[^>]*>" % childtag return r"%s\s*%s\s*%s" % (start_tag1, keyword, start_tag2) expected_exprs = [ wrap("a", "NEWSLETTER"), wrap("a", "MAILING LIST"), wrap("a", "RECIPIENTS LIST"), wrap("a", "FIRST SECOND"), wrap("a", "SECOND THIRD"), wrap("a", "THIRD, FIRST"), wrap_nest("li", "ul", "ENTRY"), wrap_nest("li", "ul", "SEE"), wrap("a", "MODULE"), wrap("a", "KEYWORD"), wrap("a", "OPERATOR"), wrap("a", "OBJECT"), wrap("a", "EXCEPTION"), wrap("a", "STATEMENT"), wrap("a", "BUILTIN"), ] for expr in expected_exprs: assert_re_search(expr, result, re.M)
def test_text_glossary_term_inconsistencies(app, warning): app.build() # --- glossary term inconsistencies: regression test for #1090 result = (app.outdir / 'glossary_terms_inconsistency.txt').text(encoding='utf-8') expect = (u"I18N WITH GLOSSARY TERMS INCONSISTENCY" u"\n**************************************\n" u"\n1. LINK TO *SOME NEW TERM*.\n") assert result == expect warnings = getwarning(warning) expected_warning_expr = ( u'.*/glossary_terms_inconsistency.txt:\\d+: ' u'WARNING: inconsistent term references in translated message\n') assert_re_search(expected_warning_expr, warnings)
def test_text_glossary_term_inconsistencies(app, warning): app.build() # --- glossary term inconsistencies: regression test for #1090 result = (app.outdir / 'glossary_terms_inconsistency.txt').read_text() expect = ("19. I18N WITH GLOSSARY TERMS INCONSISTENCY" "\n******************************************\n" "\n1. LINK TO *SOME NEW TERM*.\n") assert result == expect warnings = getwarning(warning) expected_warning_expr = ( '.*/glossary_terms_inconsistency.txt:\\d+: ' 'WARNING: inconsistent term references in translated message.' " original: \\[':term:`Some term`', ':term:`Some other term`'\\]," " translated: \\[':term:`SOME NEW TERM`'\\]\n") assert_re_search(expected_warning_expr, warnings)
def test_text_literalblock_warnings(app, warning): app.build() # --- check warning for literal block result = (app.outdir / 'literalblock.txt').read_text() expect = ("9. I18N WITH LITERAL BLOCK" "\n**************************\n" "\nCORRECT LITERAL BLOCK:\n" "\n this is" "\n literal block\n" "\nMISSING LITERAL BLOCK:\n" "\n<SYSTEM MESSAGE:") assert_startswith(result, expect) warnings = getwarning(warning) expected_warning_expr = ('.*/literalblock.txt:\\d+: ' 'WARNING: Literal block expected; none found.') assert_re_search(expected_warning_expr, warnings)
def test_text_literalblock_warnings(app, warning): app.build() # --- check warning for literal block result = (app.outdir / 'literalblock.txt').text(encoding='utf-8') expect = (u"9. I18N WITH LITERAL BLOCK" u"\n**************************\n" u"\nCORRECT LITERAL BLOCK:\n" u"\n this is" u"\n literal block\n" u"\nMISSING LITERAL BLOCK:\n" u"\n<SYSTEM MESSAGE:") assert_startswith(result, expect) warnings = getwarning(warning) expected_warning_expr = u'.*/literalblock.txt:\\d+: ' \ u'WARNING: Literal block expected; none found.' assert_re_search(expected_warning_expr, warnings)
def test_text_inconsistency_warnings(app, warning): app.build() # --- check warnings for inconsistency in number of references result = (app.outdir / 'refs_inconsistency.txt').read_text() expect = ("8. I18N WITH REFS INCONSISTENCY" "\n*******************************\n" "\n* FOR CITATION [ref3].\n" "\n* reference FOR reference.\n" "\n* ORPHAN REFERENCE: I18N WITH REFS INCONSISTENCY.\n" "\n[1] THIS IS A AUTO NUMBERED FOOTNOTE.\n" "\n[ref2] THIS IS A CITATION.\n" "\n[100] THIS IS A NUMBERED FOOTNOTE.\n") assert result == expect warnings = getwarning(warning) warning_fmt = ('.*/refs_inconsistency.txt:\\d+: ' 'WARNING: inconsistent %(reftype)s in translated message.' ' original: %(original)s, translated: %(translated)s\n') expected_warning_expr = ( warning_fmt % { 'reftype': 'footnote references', 'original': "\\['\\[#\\]_'\\]", 'translated': "\\[\\]" } + warning_fmt % { 'reftype': 'footnote references', 'original': "\\['\\[100\\]_'\\]", 'translated': "\\[\\]" } + warning_fmt % { 'reftype': 'references', 'original': "\\['reference_'\\]", 'translated': "\\['reference_', 'reference_'\\]" } + warning_fmt % { 'reftype': 'references', 'original': "\\[\\]", 'translated': "\\['`I18N WITH REFS INCONSISTENCY`_'\\]" }) assert_re_search(expected_warning_expr, warnings) expected_citation_warning_expr = ( '.*/refs_inconsistency.txt:\\d+: WARNING: Citation \\[ref2\\] is not referenced.\n' + '.*/refs_inconsistency.txt:\\d+: WARNING: citation not found: ref3') assert_re_search(expected_citation_warning_expr, warnings)
def test_text_inconsistency_warnings(app, warning): app.build() # --- check warnings for inconsistency in number of references result = (app.outdir / 'refs_inconsistency.txt').text(encoding='utf-8') expect = (u"8. I18N WITH REFS INCONSISTENCY" u"\n*******************************\n" u"\n* FOR CITATION [ref3].\n" u"\n* reference FOR reference.\n" u"\n* ORPHAN REFERENCE: I18N WITH REFS INCONSISTENCY.\n" u"\n[1] THIS IS A AUTO NUMBERED FOOTNOTE.\n" u"\n[ref2] THIS IS A CITATION.\n" u"\n[100] THIS IS A NUMBERED FOOTNOTE.\n") assert result == expect warnings = getwarning(warning) warning_fmt = u'.*/refs_inconsistency.txt:\\d+: ' \ u'WARNING: inconsistent %(reftype)s in translated message.' \ u' original: %(original)s, translated: %(translated)s\n' expected_warning_expr = ( warning_fmt % { u'reftype': u'footnote references', u'original': u"\\[u?'\\[#\\]_'\\]", u'translated': u"\\[\\]" } + warning_fmt % { u'reftype': u'footnote references', u'original': u"\\[u?'\\[100\\]_'\\]", u'translated': u"\\[\\]" } + warning_fmt % { u'reftype': u'references', u'original': u"\\[u?'reference_'\\]", u'translated': u"\\[u?'reference_', u?'reference_'\\]" } + warning_fmt % { u'reftype': u'references', u'original': u"\\[\\]", u'translated': u"\\[u?'`I18N WITH REFS INCONSISTENCY`_'\\]" }) assert_re_search(expected_warning_expr, warnings) expected_citation_warning_expr = ( u'.*/refs_inconsistency.txt:\\d+: WARNING: Citation \\[ref2\\] is not referenced.\n' + u'.*/refs_inconsistency.txt:\\d+: WARNING: citation not found: ref3') assert_re_search(expected_citation_warning_expr, warnings)
def test_text_inconsistency_warnings(app, warning): app.build() # --- check warnings for inconsistency in number of references result = (app.outdir / 'refs_inconsistency.txt').text(encoding='utf-8') expect = (u"I18N WITH REFS INCONSISTENCY" u"\n****************************\n" u"\n* FOR FOOTNOTE [ref2].\n" u"\n* reference FOR reference.\n" u"\n* ORPHAN REFERENCE: I18N WITH REFS INCONSISTENCY.\n" u"\n[1] THIS IS A AUTO NUMBERED FOOTNOTE.\n" u"\n[ref2] THIS IS A NAMED FOOTNOTE.\n" u"\n[100] THIS IS A NUMBERED FOOTNOTE.\n") assert result == expect warnings = getwarning(warning) warning_fmt = u'.*/refs_inconsistency.txt:\\d+: ' \ u'WARNING: inconsistent %s in translated message\n' expected_warning_expr = (warning_fmt % 'footnote references' + warning_fmt % 'references' + warning_fmt % 'references') assert_re_search(expected_warning_expr, warnings)
def test_text_inconsistency_warnings(app, warning): app.build() # --- check warnings for inconsistency in number of references result = (app.outdir / 'refs_inconsistency.txt').text(encoding='utf-8') expect = (u"I18N WITH REFS INCONSISTENCY" u"\n****************************\n" u"\n* FOR FOOTNOTE [ref2].\n" u"\n* reference FOR reference.\n" u"\n* ORPHAN REFERENCE: I18N WITH REFS INCONSISTENCY.\n" u"\n[1] THIS IS A AUTO NUMBERED FOOTNOTE.\n" u"\n[ref2] THIS IS A NAMED FOOTNOTE.\n" u"\n[100] THIS IS A NUMBERED FOOTNOTE.\n") assert result == expect warnings = getwarning(warning) warning_fmt = u'.*/refs_inconsistency.txt:\\d+: ' \ u'WARNING: inconsistent %s in translated message\n' expected_warning_expr = ( warning_fmt % 'footnote references' + warning_fmt % 'references' + warning_fmt % 'references') assert_re_search(expected_warning_expr, warnings)