diff options
| author | shimizukawa <shimizukawa@gmail.com> | 2013-06-21 03:28:32 +0000 |
|---|---|---|
| committer | shimizukawa <shimizukawa@gmail.com> | 2013-06-21 03:28:32 +0000 |
| commit | 2a5619b21e130d74710c717340ca52ffc516e793 (patch) | |
| tree | 5bc330c0fa98ae7f5993d917d0f5efd1e9def431 /tests | |
| parent | 3747fbde09a0f078f2f77f53f51c7a458a087549 (diff) | |
| download | sphinx-2a5619b21e130d74710c717340ca52ffc516e793.tar.gz | |
Fix i18n: footnote reference number missing for auto numbered named footnote and auto symbol footnote. Closes #1176
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/roots/test-intl/footnote.po | 7 | ||||
| -rw-r--r-- | tests/roots/test-intl/footnote.txt | 3 | ||||
| -rw-r--r-- | tests/test_intl.py | 37 |
3 files changed, 28 insertions, 19 deletions
diff --git a/tests/roots/test-intl/footnote.po b/tests/roots/test-intl/footnote.po index 47f8d3db..b3876f51 100644 --- a/tests/roots/test-intl/footnote.po +++ b/tests/roots/test-intl/footnote.po @@ -19,8 +19,8 @@ msgstr "" msgid "i18n with Footnote" msgstr "I18N WITH FOOTNOTE" -msgid "[100]_ Contents [#]_ for `i18n with Footnote`_ [ref]_" -msgstr "`I18N WITH FOOTNOTE`_ INCLUDE THIS CONTENTS [ref]_ [#]_ [100]_" +msgid "[100]_ Contents [#]_ for `i18n with Footnote`_ [ref]_ [#named]_." +msgstr "`I18N WITH FOOTNOTE`_ INCLUDE THIS CONTENTS [#named]_ [ref]_ [#]_ [100]_." msgid "This is a auto numbered footnote." msgstr "THIS IS A AUTO NUMBERED FOOTNOTE." @@ -31,3 +31,6 @@ msgstr "THIS IS A NAMED FOOTNOTE." msgid "This is a numbered footnote." msgstr "THIS IS A NUMBERED FOOTNOTE." +msgid "This is a auto numbered named footnote." +msgstr "THIS IS A AUTO NUMBERED NAMED FOOTNOTE." + diff --git a/tests/roots/test-intl/footnote.txt b/tests/roots/test-intl/footnote.txt index 3ef76bba..55da9c6d 100644 --- a/tests/roots/test-intl/footnote.txt +++ b/tests/roots/test-intl/footnote.txt @@ -4,8 +4,9 @@ i18n with Footnote ================== .. #955 cant-build-html-with-footnotes-when-using -[100]_ Contents [#]_ for `i18n with Footnote`_ [ref]_ +[100]_ Contents [#]_ for `i18n with Footnote`_ [ref]_ [#named]_. .. [#] This is a auto numbered footnote. .. [ref] This is a named footnote. .. [100] This is a numbered footnote. +.. [#named] This is a auto numbered named footnote. diff --git a/tests/test_intl.py b/tests/test_intl.py index 4c792176..ef412c1d 100644 --- a/tests/test_intl.py +++ b/tests/test_intl.py @@ -149,7 +149,7 @@ def test_i18n_footnote_break_refid(app): @with_intl_app(buildername='xml', warning=warnfile) def test_i18n_footnote_regression(app): - # regression test for fix #955 + # regression test for fix #955, #1176 app.builddir.rmtree(True) app.builder.build(['footnote']) et = ElementTree.parse(app.outdir / 'footnote.xml') @@ -159,7 +159,7 @@ def test_i18n_footnote_regression(app): assert_elem( para0[0], texts=['I18N WITH FOOTNOTE', 'INCLUDE THIS CONTENTS', - '[ref]', '1', '100'], + '2', '[ref]', '1', '100', '.'], refs=['i18n-with-footnote', 'ref']) footnote0 = secs[0].findall('footnote') @@ -171,6 +171,10 @@ def test_i18n_footnote_regression(app): footnote0[1], texts=['100','THIS IS A NUMBERED FOOTNOTE.'], names=['100']) + assert_elem( + footnote0[2], + texts=['2','THIS IS A AUTO NUMBERED NAMED FOOTNOTE.'], + names=['named']) citation0 = secs[0].findall('citation') assert_elem( @@ -183,22 +187,23 @@ def test_i18n_footnote_regression(app): assert not re.search(warning_expr, warnings) -@with_intl_app(buildername='html', cleanenv=True) +@with_intl_app(buildername='xml', cleanenv=True) def test_i18n_footnote_backlink(app): - """i18n test for #1058""" + # i18n test for #1058 app.builder.build(['footnote']) - result = (app.outdir / 'footnote.html').text(encoding='utf-8') - expects = [ - '<a class="footnote-reference" href="#id5" id="id1">[100]</a>', - '<a class="footnote-reference" href="#id4" id="id2">[1]</a>', - '<a class="reference internal" href="#ref" id="id3">[ref]</a>', - '<a class="fn-backref" href="#id2">[1]</a>', - '<a class="fn-backref" href="#id3">[ref]</a>', - '<a class="fn-backref" href="#id1">[100]</a>', - ] - for expect in expects: - matches = re.findall(re.escape(expect), result) - assert len(matches) == 1 + et = ElementTree.parse(app.outdir / 'footnote.xml') + secs = et.findall('section') + + para0 = secs[0].findall('paragraph') + refs0 = para0[0].findall('footnote_reference') + refid2id = dict([ + (r.attrib.get('refid'), r.attrib.get('ids')) for r in refs0]) + + footnote0 = secs[0].findall('footnote') + for footnote in footnote0: + ids = footnote.attrib.get('ids') + backrefs = footnote.attrib.get('backrefs') + assert refid2id[ids] == backrefs @with_intl_app(buildername='text', warning=warnfile, cleanenv=True) |
