diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2018-05-14 01:04:45 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2018-05-14 01:04:45 +0900 |
commit | bc19cf72c9cbdae03537f24e473fd0c17090047e (patch) | |
tree | 2f832d7b0b74efad4f6db2c98f91f582b6799c52 /tests/test_intl.py | |
parent | 0fe8e1fc9b014868aa3225dc618069ac70cfe6a0 (diff) | |
parent | 981e044bd512be29e7f5ac664798b965960ed39d (diff) | |
download | sphinx-git-bc19cf72c9cbdae03537f24e473fd0c17090047e.tar.gz |
Merge branch '1.7'
Diffstat (limited to 'tests/test_intl.py')
-rw-r--r-- | tests/test_intl.py | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/tests/test_intl.py b/tests/test_intl.py index b94fe85df..11e14ef84 100644 --- a/tests/test_intl.py +++ b/tests/test_intl.py @@ -307,6 +307,30 @@ def test_text_glossary_term_inconsistencies(app, warning): @sphinx_intl +@pytest.mark.sphinx('gettext') +@pytest.mark.test_params(shared_result='test_intl_gettext') +def test_gettext_section(app): + app.build() + # --- section + expect = read_po(app.srcdir / 'section.po') + actual = read_po(app.outdir / 'section.pot') + for expect_msg in [m for m in expect if m.id]: + assert expect_msg.id in [m.id for m in actual if m.id] + + +@sphinx_intl +@pytest.mark.sphinx('text') +@pytest.mark.test_params(shared_result='test_intl_basic') +def test_text_section(app): + app.build() + # --- section + result = (app.outdir / 'section.txt').text(encoding='utf-8') + expect = read_po(app.srcdir / 'section.po') + for expect_msg in [m for m in expect if m.id]: + assert expect_msg.string in result + + +@sphinx_intl @pytest.mark.sphinx('text') @pytest.mark.test_params(shared_result='test_intl_basic') def test_text_seealso(app): @@ -428,6 +452,9 @@ def test_text_admonitions(app): assert d.upper() + " TITLE" in result assert d.upper() + " BODY" in result + # for #4938 `1. ` prefixed admonition title + assert "1. ADMONITION TITLE" in result + @sphinx_intl @pytest.mark.sphinx('gettext') @@ -454,6 +481,42 @@ def test_gettext_table(app): @sphinx_intl +@pytest.mark.sphinx('text') +@pytest.mark.test_params(shared_result='test_intl_basic') +def test_text_table(app): + app.build() + # --- toctree + result = (app.outdir / 'table.txt').text(encoding='utf-8') + expect = read_po(app.srcdir / 'table.po') + for expect_msg in [m for m in expect if m.id]: + assert expect_msg.string in result + + +@sphinx_intl +@pytest.mark.sphinx('gettext') +@pytest.mark.test_params(shared_result='test_intl_gettext') +def test_gettext_topic(app): + app.build() + # --- topic + expect = read_po(app.srcdir / 'topic.po') + actual = read_po(app.outdir / 'topic.pot') + for expect_msg in [m for m in expect if m.id]: + assert expect_msg.id in [m.id for m in actual if m.id] + + +@sphinx_intl +@pytest.mark.sphinx('text') +@pytest.mark.test_params(shared_result='test_intl_basic') +def test_text_topic(app): + app.build() + # --- topic + result = (app.outdir / 'topic.txt').text(encoding='utf-8') + expect = read_po(app.srcdir / 'topic.po') + for expect_msg in [m for m in expect if m.id]: + assert expect_msg.string in result + + +@sphinx_intl @pytest.mark.sphinx('gettext') @pytest.mark.test_params(shared_result='test_intl_gettext') def test_gettext_definition_terms(app): @@ -1003,6 +1066,14 @@ def test_additional_targets_should_not_be_translated(app): """<span class="cpf"><stdio.h></span>""") assert_count(expected_expr, result, 1) + # literal block in list item should not be translated + expected_expr = ("""<span class="n">literal</span>""" + """<span class="o">-</span>""" + """<span class="n">block</span>\n""" + """<span class="k">in</span> """ + """<span class="n">list</span>""") + assert_count(expected_expr, result, 1) + # doctest block should not be translated but be highlighted expected_expr = ( """<span class="gp">>>> </span>""" @@ -1069,6 +1140,14 @@ def test_additional_targets_should_be_translated(app): """<span class="cpf"><STDIO.H></span>""") assert_count(expected_expr, result, 1) + # literal block in list item should be translated + expected_expr = ("""<span class="no">LITERAL</span>""" + """<span class="o">-</span>""" + """<span class="no">BLOCK</span>\n""" + """<span class="no">IN</span> """ + """<span class="no">LIST</span>""") + assert_count(expected_expr, result, 1) + # doctest block should not be translated but be highlighted expected_expr = ( """<span class="gp">>>> </span>""" |