fix: rescue extra named-reference that appeared in same translation message.

This commit is contained in:
Takayuki Shimizukawa
2012-12-05 20:52:19 +09:00
parent e9275d3f0c
commit bfe96c14a7
4 changed files with 25 additions and 6 deletions

View File

@@ -113,6 +113,7 @@ def test_i18n_warn_for_number_of_references_inconsistency(app):
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")
@@ -120,7 +121,7 @@ def test_i18n_warn_for_number_of_references_inconsistency(app):
warnings = warnfile.getvalue().replace(os.sep, '/')
expected_warning_expr = "i18n/refs_inconsistency.txt:\d+: WARNING: The number of reference are inconsistent in both the translated form and the untranslated form. skip translation."
assert len(re.findall(expected_warning_expr, warnings)) == 2
assert len(re.findall(expected_warning_expr, warnings)) == 3
@with_app(buildername='html', cleanenv=True,
@@ -131,11 +132,12 @@ def test_i18n_link_to_undefined_reference(app):
result = (app.outdir / 'i18n' / 'refs_inconsistency.html').text(encoding='utf-8')
expected_expr = """<a class="reference external" href="http://www.example.com">reference</a>"""
assert len(re.findall(expected_expr, result)) == 1
assert len(re.findall(expected_expr, result)) == 2
# the 2nd 'reference_' is to be internal-link instead of external-link.
# TODO: Can we re-use the same name named-reference?
expected_expr = """<a class="reference internal" href="#reference">reference</a>"""
assert len(re.findall(expected_expr, result)) == 0
expected_expr = """<a class="reference internal" href="#i18n-with-refs-inconsistency">I18N WITH REFS INCONSISTENCY</a>"""
assert len(re.findall(expected_expr, result)) == 1