diff options
Diffstat (limited to 'tests/test_intl.py')
-rw-r--r-- | tests/test_intl.py | 284 |
1 files changed, 141 insertions, 143 deletions
diff --git a/tests/test_intl.py b/tests/test_intl.py index 2d82ac1ff..fe14012f9 100644 --- a/tests/test_intl.py +++ b/tests/test_intl.py @@ -106,7 +106,7 @@ def assert_count(expected_expr, result, count): def test_text_toctree(app): app.build() result = (app.outdir / 'index.txt').text(encoding='utf-8') - assert_startswith(result, u"CONTENTS\n********\n\nTABLE OF CONTENTS\n") + assert_startswith(result, "CONTENTS\n********\n\nTABLE OF CONTENTS\n") @sphinx_intl @@ -128,9 +128,9 @@ def test_text_warning_node(app): app.build() # test warnings in translation result = (app.outdir / 'warnings.txt').text(encoding='utf-8') - expect = (u"3. I18N WITH REST WARNINGS" - u"\n**************************\n" - u"\nLINE OF >>``<<BROKEN LITERAL MARKUP.\n") + expect = ("3. I18N WITH REST WARNINGS" + "\n**************************\n" + "\nLINE OF >>``<<BROKEN LITERAL MARKUP.\n") assert result == expect @@ -142,9 +142,9 @@ def test_text_title_underline(app): app.build() # --- simple translation; check title underlines result = (app.outdir / 'bom.txt').text(encoding='utf-8') - expect = (u"2. Datei mit UTF-8" - u"\n******************\n" # underline matches new translation - u"\nThis file has umlauts: äöü.\n") + expect = ("2. Datei mit UTF-8" + "\n******************\n" # underline matches new translation + "\nThis file has umlauts: äöü.\n") assert result == expect @@ -155,7 +155,7 @@ def test_text_subdirs(app): app.build() # --- check translation in subdirs result = (app.outdir / 'subdir' / 'index.txt').text(encoding='utf-8') - assert_startswith(result, u"1. subdir contents\n******************\n") + assert_startswith(result, "1. subdir contents\n******************\n") @sphinx_intl @@ -165,46 +165,46 @@ 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") + 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 = u'.*/refs_inconsistency.txt:\\d+: ' \ - u'WARNING: inconsistent %(reftype)s in translated message.' \ - u' original: %(original)s, translated: %(translated)s\n' + 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 % { - u'reftype': u'footnote references', - u'original': u"\\[u?'\\[#\\]_'\\]", - u'translated': u"\\[\\]" + 'reftype': 'footnote references', + 'original': "\\['\\[#\\]_'\\]", + 'translated': "\\[\\]" } + warning_fmt % { - u'reftype': u'footnote references', - u'original': u"\\[u?'\\[100\\]_'\\]", - u'translated': u"\\[\\]" + 'reftype': 'footnote references', + 'original': "\\['\\[100\\]_'\\]", + 'translated': "\\[\\]" } + warning_fmt % { - u'reftype': u'references', - u'original': u"\\[u?'reference_'\\]", - u'translated': u"\\[u?'reference_', u?'reference_'\\]" + 'reftype': 'references', + 'original': "\\['reference_'\\]", + 'translated': "\\['reference_', 'reference_'\\]" } + warning_fmt % { - u'reftype': u'references', - u'original': u"\\[\\]", - u'translated': u"\\[u?'`I18N WITH REFS INCONSISTENCY`_'\\]" + 'reftype': 'references', + 'original': "\\[\\]", + 'translated': "\\['`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') + '.*/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) @@ -215,18 +215,18 @@ 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:") + 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 = u'.*/literalblock.txt:\\d+: ' \ - u'WARNING: Literal block expected; none found.' + expected_warning_expr = ('.*/literalblock.txt:\\d+: ' + 'WARNING: Literal block expected; none found.') assert_re_search(expected_warning_expr, warnings) @@ -237,17 +237,16 @@ 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"13. I18N WITH DEFINITION TERMS" - u"\n******************************\n" - u"\nSOME TERM" - u"\n THE CORRESPONDING DEFINITION\n" - u"\nSOME *TERM* WITH LINK" - u"\n THE CORRESPONDING DEFINITION #2\n" - u"\nSOME **TERM** WITH : CLASSIFIER1 : CLASSIFIER2" - u"\n THE CORRESPONDING DEFINITION\n" - u"\nSOME TERM WITH : CLASSIFIER[]" - u"\n THE CORRESPONDING DEFINITION\n" - ) + expect = ("13. I18N WITH DEFINITION TERMS" + "\n******************************\n" + "\nSOME TERM" + "\n THE CORRESPONDING DEFINITION\n" + "\nSOME *TERM* WITH LINK" + "\n THE CORRESPONDING DEFINITION #2\n" + "\nSOME **TERM** WITH : CLASSIFIER1 : CLASSIFIER2" + "\n THE CORRESPONDING DEFINITION\n" + "\nSOME TERM WITH : CLASSIFIER[]" + "\n THE CORRESPONDING DEFINITION\n") assert result == expect @@ -258,13 +257,13 @@ 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"18. I18N WITH GLOSSARY TERMS" - u"\n****************************\n" - u"\nSOME NEW TERM" - u"\n THE CORRESPONDING GLOSSARY\n" - u"\nSOME OTHER NEW TERM" - u"\n THE CORRESPONDING GLOSSARY #2\n" - u"\nLINK TO *SOME NEW TERM*.\n") + expect = ("18. I18N WITH GLOSSARY TERMS" + "\n****************************\n" + "\nSOME NEW TERM" + "\n THE CORRESPONDING GLOSSARY\n" + "\nSOME OTHER NEW TERM" + "\n THE CORRESPONDING GLOSSARY #2\n" + "\nLINK TO *SOME NEW TERM*.\n") assert result == expect warnings = getwarning(warning) assert 'term not in glossary' not in warnings @@ -277,17 +276,17 @@ 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"19. I18N WITH GLOSSARY TERMS INCONSISTENCY" - u"\n******************************************\n" - u"\n1. LINK TO *SOME NEW TERM*.\n") + 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 = ( - u'.*/glossary_terms_inconsistency.txt:\\d+: ' - u'WARNING: inconsistent term references in translated message.' - u" original: \\[u?':term:`Some term`', u?':term:`Some other term`'\\]," - u" translated: \\[u?':term:`SOME NEW TERM`'\\]\n") + '.*/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) @@ -322,12 +321,12 @@ def test_text_seealso(app): app.build() # --- seealso result = (app.outdir / 'seealso.txt').text(encoding='utf-8') - 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" - u"\n LONG TEXT 2\n") + expect = ("12. I18N WITH SEEALSO" + "\n*********************\n" + "\nSee also: SHORT TEXT 1\n" + "\nSee also: LONG TEXT 1\n" + "\nSee also: SHORT TEXT 2\n" + "\n LONG TEXT 2\n") assert result == expect @@ -338,39 +337,38 @@ 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"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"\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"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"14.3. IMAGE ON SUBSTITUTION\n" - u"===========================\n" - u"\n" - u"\n" - u"14.4. IMAGE UNDER NOTE\n" - u"======================\n" - u"\n" - u"Note: [image: i18n under note][image]\n" - u"\n" - u" [image: img under note][image]\n" - ) + expect = ("14. I18N WITH FIGURE CAPTION" + "\n****************************\n" + "\n [image]MY CAPTION OF THE FIGURE\n" + "\n MY DESCRIPTION PARAGRAPH1 OF THE FIGURE.\n" + "\n MY DESCRIPTION PARAGRAPH2 OF THE FIGURE.\n" + "\n" + "\n14.1. FIGURE IN THE BLOCK" + "\n=========================\n" + "\nBLOCK\n" + "\n [image]MY CAPTION OF THE FIGURE\n" + "\n MY DESCRIPTION PARAGRAPH1 OF THE FIGURE.\n" + "\n MY DESCRIPTION PARAGRAPH2 OF THE FIGURE.\n" + "\n" + "\n" + "14.2. IMAGE URL AND ALT\n" + "=======================\n" + "\n" + "[image: i18n][image]\n" + "\n" + " [image: img][image]\n" + "\n" + "\n" + "14.3. IMAGE ON SUBSTITUTION\n" + "===========================\n" + "\n" + "\n" + "14.4. IMAGE UNDER NOTE\n" + "======================\n" + "\n" + "Note: [image: i18n under note][image]\n" + "\n" + " [image: img under note][image]\n") assert result == expect @@ -381,14 +379,14 @@ def test_text_rubric(app): app.build() # --- rubric: regression test for pull request #190 result = (app.outdir / 'rubric.txt').text(encoding='utf-8') - expect = (u"I18N WITH RUBRIC" - u"\n****************\n" - u"\n-[ RUBRIC TITLE ]-\n" - u"\n" - u"\nRUBRIC IN THE BLOCK" - u"\n===================\n" - u"\nBLOCK\n" - u"\n -[ RUBRIC TITLE ]-\n") + expect = ("I18N WITH RUBRIC" + "\n****************\n" + "\n-[ RUBRIC TITLE ]-\n" + "\n" + "\nRUBRIC IN THE BLOCK" + "\n===================\n" + "\nBLOCK\n" + "\n -[ RUBRIC TITLE ]-\n") assert result == expect @@ -399,25 +397,25 @@ def test_text_docfields(app): app.build() # --- docfields result = (app.outdir / 'docfields.txt').text(encoding='utf-8') - expect = (u"21. I18N WITH DOCFIELDS" - u"\n***********************\n" - u"\nclass Cls1\n" - u"\n Parameters:" - u"\n **param** -- DESCRIPTION OF PARAMETER param\n" - u"\nclass Cls2\n" - u"\n Parameters:" - u"\n * **foo** -- DESCRIPTION OF PARAMETER foo\n" - u"\n * **bar** -- DESCRIPTION OF PARAMETER bar\n" - u"\nclass Cls3(values)\n" - u"\n Raises:" - u"\n **ValueError** -- IF THE VALUES ARE OUT OF RANGE\n" - u"\nclass Cls4(values)\n" - u"\n Raises:" - u"\n * **TypeError** -- IF THE VALUES ARE NOT VALID\n" - u"\n * **ValueError** -- IF THE VALUES ARE OUT OF RANGE\n" - u"\nclass Cls5\n" - u"\n Returns:" - u'\n A NEW "Cls3" INSTANCE\n') + expect = ("21. I18N WITH DOCFIELDS" + "\n***********************\n" + "\nclass Cls1\n" + "\n Parameters:" + "\n **param** -- DESCRIPTION OF PARAMETER param\n" + "\nclass Cls2\n" + "\n Parameters:" + "\n * **foo** -- DESCRIPTION OF PARAMETER foo\n" + "\n * **bar** -- DESCRIPTION OF PARAMETER bar\n" + "\nclass Cls3(values)\n" + "\n Raises:" + "\n **ValueError** -- IF THE VALUES ARE OUT OF RANGE\n" + "\nclass Cls4(values)\n" + "\n Raises:" + "\n * **TypeError** -- IF THE VALUES ARE NOT VALID\n" + "\n * **ValueError** -- IF THE VALUES ARE OUT OF RANGE\n" + "\nclass Cls5\n" + "\n Returns:" + '\n A NEW "Cls3" INSTANCE\n') assert result == expect @@ -708,21 +706,21 @@ def test_html_versionchanges(app): return '' expect1 = ( - u"""<p><span class="versionmodified">Deprecated since version 1.0: </span>""" - u"""THIS IS THE <em>FIRST</em> PARAGRAPH OF DEPRECATED.</p>\n""" - u"""<p>THIS IS THE <em>SECOND</em> PARAGRAPH OF DEPRECATED.</p>\n""") + """<p><span class="versionmodified">Deprecated since version 1.0: </span>""" + """THIS IS THE <em>FIRST</em> PARAGRAPH OF DEPRECATED.</p>\n""" + """<p>THIS IS THE <em>SECOND</em> PARAGRAPH OF DEPRECATED.</p>\n""") matched_content = get_content(result, "deprecated") assert expect1 == matched_content expect2 = ( - u"""<p><span class="versionmodified">New in version 1.0: </span>""" - u"""THIS IS THE <em>FIRST</em> PARAGRAPH OF VERSIONADDED.</p>\n""") + """<p><span class="versionmodified">New in version 1.0: </span>""" + """THIS IS THE <em>FIRST</em> PARAGRAPH OF VERSIONADDED.</p>\n""") matched_content = get_content(result, "versionadded") assert expect2 == matched_content expect3 = ( - u"""<p><span class="versionmodified">Changed in version 1.0: </span>""" - u"""THIS IS THE <em>FIRST</em> PARAGRAPH OF VERSIONCHANGED.</p>\n""") + """<p><span class="versionmodified">Changed in version 1.0: </span>""" + """THIS IS THE <em>FIRST</em> PARAGRAPH OF VERSIONCHANGED.</p>\n""") matched_content = get_content(result, "versionchanged") assert expect3 == matched_content @@ -816,7 +814,7 @@ def test_xml_footnotes(app, warning): ['ref']) warnings = getwarning(warning) - warning_expr = u'.*/footnote.xml:\\d*: SEVERE: Duplicate ID: ".*".\n' + warning_expr = '.*/footnote.xml:\\d*: SEVERE: Duplicate ID: ".*".\n' assert_not_re_search(warning_expr, warnings) @@ -1177,7 +1175,7 @@ def test_text_references(app, warning): app.builder.build_specific([app.srcdir / 'refs.txt']) warnings = warning.getvalue().replace(os.sep, '/') - warning_expr = u'refs.txt:\\d+: ERROR: Unknown target name:' + warning_expr = 'refs.txt:\\d+: ERROR: Unknown target name:' assert_count(warning_expr, warnings, 0) @@ -1231,7 +1229,7 @@ def test_image_glob_intl(app): srcdir='test_intl_images', confoverrides={ 'language': 'xx', - 'figure_language_filename': u'{root}{ext}.{language}', + 'figure_language_filename': '{root}{ext}.{language}', } ) @pytest.mark.xfail(os.name != 'posix', reason="Not working on windows") |