mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Divide test_intl target source files for speed-up.
This commit is contained in:
parent
64a4c13d63
commit
9b9c69042e
@ -28,7 +28,6 @@ Contents:
|
|||||||
extensions
|
extensions
|
||||||
versioning/index
|
versioning/index
|
||||||
footnote
|
footnote
|
||||||
i18n/index
|
|
||||||
|
|
||||||
Python <http://python.org/>
|
Python <http://python.org/>
|
||||||
|
|
||||||
|
12
tests/roots/test-intl/bom.po
Normal file
12
tests/roots/test-intl/bom.po
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#, fuzzy
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
|
||||||
|
msgid "File with UTF-8 BOM"
|
||||||
|
msgstr "Datei mit UTF-8"
|
||||||
|
|
||||||
|
msgid "This file has a UTF-8 \"BOM\"."
|
||||||
|
msgstr "This file has umlauts: äöü."
|
5
tests/roots/test-intl/bom.txt
Normal file
5
tests/roots/test-intl/bom.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
File with UTF-8 BOM
|
||||||
|
===================
|
||||||
|
|
||||||
|
This file has a UTF-8 "BOM".
|
||||||
|
|
7
tests/roots/test-intl/conf.py
Normal file
7
tests/roots/test-intl/conf.py
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import sys, os
|
||||||
|
|
||||||
|
project = 'Sphinx intl <Tests>'
|
||||||
|
source_suffix = '.txt'
|
||||||
|
keep_warnings = True
|
@ -2,6 +2,8 @@
|
|||||||
:maxdepth: 2
|
:maxdepth: 2
|
||||||
:numbered:
|
:numbered:
|
||||||
|
|
||||||
|
subdir/contents
|
||||||
|
bom
|
||||||
footnote
|
footnote
|
||||||
external_links
|
external_links
|
||||||
refs_inconsistency
|
refs_inconsistency
|
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 66 KiB |
2
tests/roots/test-intl/subdir/contents.txt
Normal file
2
tests/roots/test-intl/subdir/contents.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
subdir contents
|
||||||
|
===============
|
@ -20,6 +20,7 @@ from util import SkipTest
|
|||||||
|
|
||||||
def teardown_module():
|
def teardown_module():
|
||||||
(test_root / '_build').rmtree(True)
|
(test_root / '_build').rmtree(True)
|
||||||
|
(test_roots / 'test-intl' / '_build').rmtree(True),
|
||||||
|
|
||||||
|
|
||||||
@with_app(buildername='gettext')
|
@with_app(buildername='gettext')
|
||||||
@ -83,10 +84,12 @@ def test_gettext(app):
|
|||||||
|
|
||||||
|
|
||||||
@with_app(buildername='gettext',
|
@with_app(buildername='gettext',
|
||||||
|
srcdir=(test_roots / 'test-intl'),
|
||||||
|
doctreedir=(test_roots / 'test-intl' / '_build' / 'doctree'),
|
||||||
confoverrides={'gettext_compact': False})
|
confoverrides={'gettext_compact': False})
|
||||||
def test_gettext_index_entries(app):
|
def test_gettext_index_entries(app):
|
||||||
# regression test for #976
|
# regression test for #976
|
||||||
app.builder.build(['i18n/index_entries'])
|
app.builder.build(['index_entries'])
|
||||||
|
|
||||||
_msgid_getter = re.compile(r'msgid "(.*)"').search
|
_msgid_getter = re.compile(r'msgid "(.*)"').search
|
||||||
def msgid_getter(msgid):
|
def msgid_getter(msgid):
|
||||||
@ -95,7 +98,7 @@ def test_gettext_index_entries(app):
|
|||||||
return m.groups()[0]
|
return m.groups()[0]
|
||||||
return None
|
return None
|
||||||
|
|
||||||
pot = (app.outdir / 'i18n' / 'index_entries.pot').text(encoding='utf-8')
|
pot = (app.outdir / 'index_entries.pot').text(encoding='utf-8')
|
||||||
msgids = filter(None, map(msgid_getter, pot.splitlines()))
|
msgids = filter(None, map(msgid_getter, pot.splitlines()))
|
||||||
|
|
||||||
expected_msgids = [
|
expected_msgids = [
|
||||||
|
@ -35,7 +35,6 @@ ENV_WARNINGS = """\
|
|||||||
%(root)s/autodoc_fodder.py:docstring of autodoc_fodder\\.MarkupError:2: \
|
%(root)s/autodoc_fodder.py:docstring of autodoc_fodder\\.MarkupError:2: \
|
||||||
WARNING: Explicit markup ends without a blank line; unexpected \
|
WARNING: Explicit markup ends without a blank line; unexpected \
|
||||||
unindent\\.\\n?
|
unindent\\.\\n?
|
||||||
%(root)s/i18n/literalblock.txt:13: WARNING: Literal block expected; none found.
|
|
||||||
%(root)s/images.txt:9: WARNING: image file not readable: foo.png
|
%(root)s/images.txt:9: WARNING: image file not readable: foo.png
|
||||||
%(root)s/images.txt:23: WARNING: nonlocal image URI found: \
|
%(root)s/images.txt:23: WARNING: nonlocal image URI found: \
|
||||||
http://www.python.org/logo.png
|
http://www.python.org/logo.png
|
||||||
|
@ -22,19 +22,34 @@ from util import SkipTest
|
|||||||
|
|
||||||
|
|
||||||
warnfile = StringIO()
|
warnfile = StringIO()
|
||||||
|
root = test_roots / 'test-intl'
|
||||||
|
doctreedir = root / '_build' / 'doctree'
|
||||||
|
|
||||||
|
|
||||||
|
def with_intl_app(*args, **kw):
|
||||||
|
default_kw = {
|
||||||
|
'srcdir': root,
|
||||||
|
'doctreedir': doctreedir,
|
||||||
|
'confoverrides': {
|
||||||
|
'language': 'xx', 'locale_dirs': ['.'],
|
||||||
|
'gettext_compact': False,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
default_kw.update(kw)
|
||||||
|
return with_app(*args, **default_kw)
|
||||||
|
|
||||||
|
|
||||||
def setup_module():
|
def setup_module():
|
||||||
# Delete remnants left over after failed build
|
# Delete remnants left over after failed build
|
||||||
(test_root / 'xx').rmtree(True)
|
(root / 'xx').rmtree(True)
|
||||||
(test_root / 'xx' / 'LC_MESSAGES').makedirs()
|
(root / 'xx' / 'LC_MESSAGES').makedirs()
|
||||||
# Compile all required catalogs into binary format (*.mo).
|
# Compile all required catalogs into binary format (*.mo).
|
||||||
for dirpath, dirs, files in os.walk(test_root):
|
for dirpath, dirs, files in os.walk(root):
|
||||||
dirpath = path(dirpath)
|
dirpath = path(dirpath)
|
||||||
for f in [f for f in files if f.endswith('.po')]:
|
for f in [f for f in files if f.endswith('.po')]:
|
||||||
po = dirpath / f
|
po = dirpath / f
|
||||||
mo = test_root / 'xx' / 'LC_MESSAGES' / (
|
mo = root / 'xx' / 'LC_MESSAGES' / (
|
||||||
relpath(po[:-3], test_root) + '.mo')
|
relpath(po[:-3], root) + '.mo')
|
||||||
if not mo.parent.exists():
|
if not mo.parent.exists():
|
||||||
mo.parent.makedirs()
|
mo.parent.makedirs()
|
||||||
try:
|
try:
|
||||||
@ -52,12 +67,11 @@ def setup_module():
|
|||||||
|
|
||||||
|
|
||||||
def teardown_module():
|
def teardown_module():
|
||||||
(test_root / '_build').rmtree(True)
|
(root / '_build').rmtree(True)
|
||||||
(test_root / 'xx').rmtree(True)
|
(root / 'xx').rmtree(True)
|
||||||
|
|
||||||
|
|
||||||
@with_app(buildername='text',
|
@with_intl_app(buildername='text')
|
||||||
confoverrides={'language': 'xx', 'locale_dirs': ['.']})
|
|
||||||
def test_simple(app):
|
def test_simple(app):
|
||||||
app.builder.build(['bom'])
|
app.builder.build(['bom'])
|
||||||
result = (app.outdir / 'bom.txt').text(encoding='utf-8')
|
result = (app.outdir / 'bom.txt').text(encoding='utf-8')
|
||||||
@ -67,31 +81,26 @@ def test_simple(app):
|
|||||||
assert result == expect
|
assert result == expect
|
||||||
|
|
||||||
|
|
||||||
@with_app(buildername='text',
|
@with_intl_app(buildername='text')
|
||||||
confoverrides={'language': 'xx', 'locale_dirs': ['.']})
|
|
||||||
def test_subdir(app):
|
def test_subdir(app):
|
||||||
app.builder.build(['subdir/includes'])
|
app.builder.build(['subdir/contents'])
|
||||||
result = (app.outdir / 'subdir' / 'includes.txt').text(encoding='utf-8')
|
result = (app.outdir / 'subdir' / 'contents.txt').text(encoding='utf-8')
|
||||||
assert result.startswith(u"\ntranslation\n***********\n\n")
|
assert result.startswith(u"\nsubdir contents\n***************\n")
|
||||||
|
|
||||||
|
|
||||||
@with_app(buildername='html', cleanenv=True,
|
@with_intl_app(buildername='html', cleanenv=True)
|
||||||
confoverrides={'language': 'xx', 'locale_dirs': ['.'],
|
|
||||||
'gettext_compact': False})
|
|
||||||
def test_i18n_footnote_break_refid(app):
|
def test_i18n_footnote_break_refid(app):
|
||||||
"""test for #955 cant-build-html-with-footnotes-when-using"""
|
"""test for #955 cant-build-html-with-footnotes-when-using"""
|
||||||
app.builder.build(['i18n/footnote'])
|
app.builder.build(['footnote'])
|
||||||
result = (app.outdir / 'i18n' / 'footnote.html').text(encoding='utf-8')
|
result = (app.outdir / 'footnote.html').text(encoding='utf-8')
|
||||||
# expect no error by build
|
# expect no error by build
|
||||||
|
|
||||||
|
|
||||||
@with_app(buildername='text', cleanenv=True,
|
@with_intl_app(buildername='text', cleanenv=True)
|
||||||
confoverrides={'language': 'xx', 'locale_dirs': ['.'],
|
|
||||||
'gettext_compact': False})
|
|
||||||
def test_i18n_footnote_regression(app):
|
def test_i18n_footnote_regression(app):
|
||||||
"""regression test for fix #955"""
|
"""regression test for fix #955"""
|
||||||
app.builder.build(['i18n/footnote'])
|
app.builder.build(['footnote'])
|
||||||
result = (app.outdir / 'i18n' / 'footnote.txt').text(encoding='utf-8')
|
result = (app.outdir / 'footnote.txt').text(encoding='utf-8')
|
||||||
expect = (u"\nI18N WITH FOOTNOTE"
|
expect = (u"\nI18N WITH FOOTNOTE"
|
||||||
u"\n******************\n" # underline matches new translation
|
u"\n******************\n" # underline matches new translation
|
||||||
u"\nI18N WITH FOOTNOTE INCLUDE THIS CONTENTS [ref] [1] [100]\n"
|
u"\nI18N WITH FOOTNOTE INCLUDE THIS CONTENTS [ref] [1] [100]\n"
|
||||||
@ -101,13 +110,11 @@ def test_i18n_footnote_regression(app):
|
|||||||
assert result == expect
|
assert result == expect
|
||||||
|
|
||||||
|
|
||||||
@with_app(buildername='html', cleanenv=True,
|
@with_intl_app(buildername='html', cleanenv=True)
|
||||||
confoverrides={'language': 'xx', 'locale_dirs': ['.'],
|
|
||||||
'gettext_compact': False})
|
|
||||||
def test_i18n_footnote_backlink(app):
|
def test_i18n_footnote_backlink(app):
|
||||||
"""i18n test for #1058"""
|
"""i18n test for #1058"""
|
||||||
app.builder.build(['i18n/footnote'])
|
app.builder.build(['footnote'])
|
||||||
result = (app.outdir / 'i18n' / 'footnote.html').text(encoding='utf-8')
|
result = (app.outdir / 'footnote.html').text(encoding='utf-8')
|
||||||
expects = [
|
expects = [
|
||||||
'<a class="footnote-reference" href="#id5" id="id1">[100]</a>',
|
'<a class="footnote-reference" href="#id5" id="id1">[100]</a>',
|
||||||
'<a class="footnote-reference" href="#id4" id="id2">[1]</a>',
|
'<a class="footnote-reference" href="#id4" id="id2">[1]</a>',
|
||||||
@ -121,13 +128,11 @@ def test_i18n_footnote_backlink(app):
|
|||||||
assert len(matches) == 1
|
assert len(matches) == 1
|
||||||
|
|
||||||
|
|
||||||
@with_app(buildername='text', warning=warnfile, cleanenv=True,
|
@with_intl_app(buildername='text', warning=warnfile, cleanenv=True)
|
||||||
confoverrides={'language': 'xx', 'locale_dirs': ['.'],
|
|
||||||
'gettext_compact': False})
|
|
||||||
def test_i18n_warn_for_number_of_references_inconsistency(app):
|
def test_i18n_warn_for_number_of_references_inconsistency(app):
|
||||||
app.builddir.rmtree(True)
|
app.builddir.rmtree(True)
|
||||||
app.builder.build(['i18n/refs_inconsistency'])
|
app.builder.build(['refs_inconsistency'])
|
||||||
result = (app.outdir / 'i18n' / 'refs_inconsistency.txt').text(encoding='utf-8')
|
result = (app.outdir / 'refs_inconsistency.txt').text(encoding='utf-8')
|
||||||
expect = (u"\nI18N WITH REFS INCONSISTENCY"
|
expect = (u"\nI18N WITH REFS INCONSISTENCY"
|
||||||
u"\n****************************\n"
|
u"\n****************************\n"
|
||||||
u"\n* FOR FOOTNOTE [ref2].\n"
|
u"\n* FOR FOOTNOTE [ref2].\n"
|
||||||
@ -139,7 +144,7 @@ def test_i18n_warn_for_number_of_references_inconsistency(app):
|
|||||||
assert result == expect
|
assert result == expect
|
||||||
|
|
||||||
warnings = warnfile.getvalue().replace(os.sep, '/')
|
warnings = warnfile.getvalue().replace(os.sep, '/')
|
||||||
warning_fmt = u'.*/i18n/refs_inconsistency.txt:\\d+: ' \
|
warning_fmt = u'.*/refs_inconsistency.txt:\\d+: ' \
|
||||||
u'WARNING: inconsistent %s in translated message\n'
|
u'WARNING: inconsistent %s in translated message\n'
|
||||||
expected_warning_expr = (
|
expected_warning_expr = (
|
||||||
warning_fmt % 'footnote references' +
|
warning_fmt % 'footnote references' +
|
||||||
@ -148,12 +153,10 @@ def test_i18n_warn_for_number_of_references_inconsistency(app):
|
|||||||
assert re.search(expected_warning_expr, warnings)
|
assert re.search(expected_warning_expr, warnings)
|
||||||
|
|
||||||
|
|
||||||
@with_app(buildername='html', cleanenv=True,
|
@with_intl_app(buildername='html', cleanenv=True)
|
||||||
confoverrides={'language': 'xx', 'locale_dirs': ['.'],
|
|
||||||
'gettext_compact': False})
|
|
||||||
def test_i18n_link_to_undefined_reference(app):
|
def test_i18n_link_to_undefined_reference(app):
|
||||||
app.builder.build(['i18n/refs_inconsistency'])
|
app.builder.build(['refs_inconsistency'])
|
||||||
result = (app.outdir / 'i18n' / 'refs_inconsistency.html').text(encoding='utf-8')
|
result = (app.outdir / 'refs_inconsistency.html').text(encoding='utf-8')
|
||||||
|
|
||||||
expected_expr = """<a class="reference external" href="http://www.example.com">reference</a>"""
|
expected_expr = """<a class="reference external" href="http://www.example.com">reference</a>"""
|
||||||
assert len(re.findall(expected_expr, result)) == 2
|
assert len(re.findall(expected_expr, result)) == 2
|
||||||
@ -165,13 +168,11 @@ def test_i18n_link_to_undefined_reference(app):
|
|||||||
assert len(re.findall(expected_expr, result)) == 1
|
assert len(re.findall(expected_expr, result)) == 1
|
||||||
|
|
||||||
|
|
||||||
@with_app(buildername='html', cleanenv=True,
|
@with_intl_app(buildername='html', cleanenv=True)
|
||||||
confoverrides={'language': 'xx', 'locale_dirs': ['.'],
|
|
||||||
'gettext_compact': False})
|
|
||||||
def test_i18n_keep_external_links(app):
|
def test_i18n_keep_external_links(app):
|
||||||
"""regression test for #1044"""
|
"""regression test for #1044"""
|
||||||
app.builder.build(['i18n/external_links'])
|
app.builder.build(['external_links'])
|
||||||
result = (app.outdir / 'i18n' / 'external_links.html').text(encoding='utf-8')
|
result = (app.outdir / 'external_links.html').text(encoding='utf-8')
|
||||||
|
|
||||||
# external link check
|
# external link check
|
||||||
expect_line = u"""<li>EXTERNAL LINK TO <a class="reference external" href="http://python.org">Python</a>.</li>"""
|
expect_line = u"""<li>EXTERNAL LINK TO <a class="reference external" href="http://python.org">Python</a>.</li>"""
|
||||||
@ -206,13 +207,11 @@ def test_i18n_keep_external_links(app):
|
|||||||
assert expect_line == matched_line
|
assert expect_line == matched_line
|
||||||
|
|
||||||
|
|
||||||
@with_app(buildername='text', warning=warnfile, cleanenv=True,
|
@with_intl_app(buildername='text', warning=warnfile, cleanenv=True)
|
||||||
confoverrides={'language': 'xx', 'locale_dirs': ['.'],
|
|
||||||
'gettext_compact': False})
|
|
||||||
def test_i18n_literalblock_warning(app):
|
def test_i18n_literalblock_warning(app):
|
||||||
app.builddir.rmtree(True) #for warnings acceleration
|
app.builddir.rmtree(True) #for warnings acceleration
|
||||||
app.builder.build(['i18n/literalblock'])
|
app.builder.build(['literalblock'])
|
||||||
result = (app.outdir / 'i18n' / 'literalblock.txt').text(encoding='utf-8')
|
result = (app.outdir / 'literalblock.txt').text(encoding='utf-8')
|
||||||
expect = (u"\nI18N WITH LITERAL BLOCK"
|
expect = (u"\nI18N WITH LITERAL BLOCK"
|
||||||
u"\n***********************\n"
|
u"\n***********************\n"
|
||||||
u"\nCORRECT LITERAL BLOCK:\n"
|
u"\nCORRECT LITERAL BLOCK:\n"
|
||||||
@ -223,18 +222,16 @@ def test_i18n_literalblock_warning(app):
|
|||||||
assert result.startswith(expect)
|
assert result.startswith(expect)
|
||||||
|
|
||||||
warnings = warnfile.getvalue().replace(os.sep, '/')
|
warnings = warnfile.getvalue().replace(os.sep, '/')
|
||||||
expected_warning_expr = u'.*/i18n/literalblock.txt:\\d+: ' \
|
expected_warning_expr = u'.*/literalblock.txt:\\d+: ' \
|
||||||
u'WARNING: Literal block expected; none found.'
|
u'WARNING: Literal block expected; none found.'
|
||||||
assert re.search(expected_warning_expr, warnings)
|
assert re.search(expected_warning_expr, warnings)
|
||||||
|
|
||||||
|
|
||||||
@with_app(buildername='text',
|
@with_intl_app(buildername='text')
|
||||||
confoverrides={'language': 'xx', 'locale_dirs': ['.'],
|
|
||||||
'gettext_compact': False})
|
|
||||||
def test_i18n_definition_terms(app):
|
def test_i18n_definition_terms(app):
|
||||||
# regression test for #975
|
# regression test for #975
|
||||||
app.builder.build(['i18n/definition_terms'])
|
app.builder.build(['definition_terms'])
|
||||||
result = (app.outdir / 'i18n' / 'definition_terms.txt').text(encoding='utf-8')
|
result = (app.outdir / 'definition_terms.txt').text(encoding='utf-8')
|
||||||
expect = (u"\nI18N WITH DEFINITION TERMS"
|
expect = (u"\nI18N WITH DEFINITION TERMS"
|
||||||
u"\n**************************\n"
|
u"\n**************************\n"
|
||||||
u"\nSOME TERM"
|
u"\nSOME TERM"
|
||||||
@ -245,13 +242,11 @@ def test_i18n_definition_terms(app):
|
|||||||
assert result == expect
|
assert result == expect
|
||||||
|
|
||||||
|
|
||||||
@with_app(buildername='text',
|
@with_intl_app(buildername='text')
|
||||||
confoverrides={'language': 'xx', 'locale_dirs': ['.'],
|
|
||||||
'gettext_compact': False})
|
|
||||||
def test_i18n_figure_caption(app):
|
def test_i18n_figure_caption(app):
|
||||||
# regression test for #940
|
# regression test for #940
|
||||||
app.builder.build(['i18n/figure_caption'])
|
app.builder.build(['figure_caption'])
|
||||||
result = (app.outdir / 'i18n' / 'figure_caption.txt').text(encoding='utf-8')
|
result = (app.outdir / 'figure_caption.txt').text(encoding='utf-8')
|
||||||
expect = (u"\nI18N WITH FIGURE CAPTION"
|
expect = (u"\nI18N WITH FIGURE CAPTION"
|
||||||
u"\n************************\n"
|
u"\n************************\n"
|
||||||
u"\n [image]MY CAPTION OF THE FIGURE\n"
|
u"\n [image]MY CAPTION OF THE FIGURE\n"
|
||||||
@ -261,12 +256,10 @@ def test_i18n_figure_caption(app):
|
|||||||
assert result == expect
|
assert result == expect
|
||||||
|
|
||||||
|
|
||||||
@with_app(buildername='html',
|
@with_intl_app(buildername='html')
|
||||||
confoverrides={'language': 'xx', 'locale_dirs': ['.'],
|
|
||||||
'gettext_compact': False})
|
|
||||||
def test_i18n_index_entries(app):
|
def test_i18n_index_entries(app):
|
||||||
# regression test for #976
|
# regression test for #976
|
||||||
app.builder.build(['i18n/index_entries'])
|
app.builder.build(['index_entries'])
|
||||||
result = (app.outdir / 'genindex.html').text(encoding='utf-8')
|
result = (app.outdir / 'genindex.html').text(encoding='utf-8')
|
||||||
|
|
||||||
def wrap(tag, keyword):
|
def wrap(tag, keyword):
|
||||||
|
Loading…
Reference in New Issue
Block a user