test: Fix broken testcases

This commit is contained in:
Takeshi KOMIYA 2018-01-15 01:01:13 +09:00
parent 18dfe37f8c
commit dc3d03da1b
2 changed files with 55 additions and 56 deletions

View File

@ -63,7 +63,7 @@ def test_lineblock(app, status, warning):
def test_nonascii_title_line(app, status, warning):
app.builder.build_update()
result = (app.outdir / 'nonascii_title.txt').text(encoding='utf-8')
expect_underline = '******'
expect_underline = '*********'
result_underline = result.splitlines()[1].strip()
assert expect_underline == result_underline
@ -114,32 +114,6 @@ def test_list_items_in_admonition(app, status, warning):
@with_text_app()
def test_secnums(app, status, warning):
app.builder.build_all()
contents = (app.outdir / 'contents.txt').text(encoding='utf8')
lines = contents.splitlines()
assert lines[0] == "* Section A"
assert lines[1] == ""
assert lines[2] == "* Section B"
assert lines[3] == ""
assert lines[4] == " * Sub Ba"
assert lines[5] == ""
assert lines[6] == " * Sub Bb"
doc2 = (app.outdir / 'doc2.txt').text(encoding='utf8')
expect = (
"Section B\n"
"*********\n"
"\n"
"\n"
"Sub Ba\n"
"======\n"
"\n"
"\n"
"Sub Bb\n"
"======\n"
)
assert doc2 == expect
app.config.text_add_secnumbers = True
app.builder.build_all()
contents = (app.outdir / 'contents.txt').text(encoding='utf8')
lines = contents.splitlines()
@ -191,3 +165,28 @@ def test_secnums(app, status, warning):
)
assert doc2 == expect
app.config.text_add_secnumbers = False
app.builder.build_all()
contents = (app.outdir / 'contents.txt').text(encoding='utf8')
lines = contents.splitlines()
assert lines[0] == "* Section A"
assert lines[1] == ""
assert lines[2] == "* Section B"
assert lines[3] == ""
assert lines[4] == " * Sub Ba"
assert lines[5] == ""
assert lines[6] == " * Sub Bb"
doc2 = (app.outdir / 'doc2.txt').text(encoding='utf8')
expect = (
"Section B\n"
"*********\n"
"\n"
"\n"
"Sub Ba\n"
"======\n"
"\n"
"\n"
"Sub Bb\n"
"======\n"
)
assert doc2 == expect

View File

@ -143,8 +143,8 @@ def test_text_warning_node(app):
app.build()
# test warnings in translation
result = (app.outdir / 'warnings.txt').text(encoding='utf-8')
expect = (u"I18N WITH REST WARNINGS"
u"\n***********************\n"
expect = (u"3. I18N WITH REST WARNINGS"
u"\n**************************\n"
u"\nLINE OF >>``<<BROKEN LITERAL MARKUP.\n")
assert result == expect
@ -157,8 +157,8 @@ def test_text_title_underline(app):
app.build()
# --- simple translation; check title underlines
result = (app.outdir / 'bom.txt').text(encoding='utf-8')
expect = (u"Datei mit UTF-8"
u"\n***************\n" # underline matches new translation
expect = (u"2. Datei mit UTF-8"
u"\n******************\n" # underline matches new translation
u"\nThis file has umlauts: äöü.\n")
assert result == expect
@ -170,7 +170,7 @@ def test_text_subdirs(app):
app.build()
# --- check translation in subdirs
result = (app.outdir / 'subdir' / 'contents.txt').text(encoding='utf-8')
assert_startswith(result, u"subdir contents\n***************\n")
assert_startswith(result, u"1. subdir contents\n******************\n")
@sphinx_intl
@ -180,8 +180,8 @@ 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"
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"
@ -230,8 +230,8 @@ 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"I18N WITH LITERAL BLOCK"
u"\n***********************\n"
expect = (u"9. I18N WITH LITERAL BLOCK"
u"\n**************************\n"
u"\nCORRECT LITERAL BLOCK:\n"
u"\n this is"
u"\n literal block\n"
@ -252,8 +252,8 @@ def test_text_definition_terms(app):
app.build()
# --- definition terms: regression test for #975, #2198, #2205
result = (app.outdir / 'definition_terms.txt').text(encoding='utf-8')
expect = (u"I18N WITH DEFINITION TERMS"
u"\n**************************\n"
expect = (u"13. I18N WITH DEFINITION TERMS"
u"\n******************************\n"
u"\nSOME TERM"
u"\n THE CORRESPONDING DEFINITION\n"
u"\nSOME *TERM* WITH LINK"
@ -273,8 +273,8 @@ def test_text_glossary_term(app, warning):
app.build()
# --- glossary terms: regression test for #1090
result = (app.outdir / 'glossary_terms.txt').text(encoding='utf-8')
expect = (u"I18N WITH GLOSSARY TERMS"
u"\n************************\n"
expect = (u"18. I18N WITH GLOSSARY TERMS"
u"\n****************************\n"
u"\nSOME NEW TERM"
u"\n THE CORRESPONDING GLOSSARY\n"
u"\nSOME OTHER NEW TERM"
@ -292,8 +292,8 @@ 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"
expect = (u"19. I18N WITH GLOSSARY TERMS INCONSISTENCY"
u"\n******************************************\n"
u"\n1. LINK TO *SOME NEW TERM*.\n")
assert result == expect
@ -313,8 +313,8 @@ def test_text_seealso(app):
app.build()
# --- seealso
result = (app.outdir / 'seealso.txt').text(encoding='utf-8')
expect = (u"I18N WITH SEEALSO"
u"\n*****************\n"
expect = (u"12. I18N WITH SEEALSO"
u"\n*********************\n"
u"\nSee also: SHORT TEXT 1\n"
u"\nSee also: LONG TEXT 1\n"
u"\nSee also: SHORT TEXT 2\n"
@ -329,34 +329,34 @@ def test_text_figure_captions(app):
app.build()
# --- figure captions: regression test for #940
result = (app.outdir / 'figure.txt').text(encoding='utf-8')
expect = (u"I18N WITH FIGURE CAPTION"
u"\n************************\n"
expect = (u"14. I18N WITH FIGURE CAPTION"
u"\n****************************\n"
u"\n [image]MY CAPTION OF THE FIGURE\n"
u"\n MY DESCRIPTION PARAGRAPH1 OF THE FIGURE.\n"
u"\n MY DESCRIPTION PARAGRAPH2 OF THE FIGURE.\n"
u"\n"
u"\nFIGURE IN THE BLOCK"
u"\n===================\n"
u"\n14.1. FIGURE IN THE BLOCK"
u"\n=========================\n"
u"\nBLOCK\n"
u"\n [image]MY CAPTION OF THE FIGURE\n"
u"\n MY DESCRIPTION PARAGRAPH1 OF THE FIGURE.\n"
u"\n MY DESCRIPTION PARAGRAPH2 OF THE FIGURE.\n"
u"\n"
u"\n"
u"IMAGE URL AND ALT\n"
u"=================\n"
u"14.2. IMAGE URL AND ALT\n"
u"=======================\n"
u"\n"
u"[image: i18n][image]\n"
u"\n"
u" [image: img][image]\n"
u"\n"
u"\n"
u"IMAGE ON SUBSTITUTION\n"
u"=====================\n"
u"14.3. IMAGE ON SUBSTITUTION\n"
u"===========================\n"
u"\n"
u"\n"
u"IMAGE UNDER NOTE\n"
u"================\n"
u"14.4. IMAGE UNDER NOTE\n"
u"======================\n"
u"\n"
u"Note: [image: i18n under note][image]\n"
u"\n"
@ -390,8 +390,8 @@ def test_text_docfields(app):
app.build()
# --- docfields
result = (app.outdir / 'docfields.txt').text(encoding='utf-8')
expect = (u"I18N WITH DOCFIELDS"
u"\n*******************\n"
expect = (u"21. I18N WITH DOCFIELDS"
u"\n***********************\n"
u"\nclass Cls1\n"
u"\n Parameters:"
u"\n **param** -- DESCRIPTION OF PARAMETER param\n"