From 07d2cdd47b9bb5319a2de11ab514b956379068ab Mon Sep 17 00:00:00 2001 From: cocoatomo Date: Sun, 18 Feb 2018 09:05:32 +0900 Subject: [PATCH] Add a testcase for deterministic msgid order --- .../test-intl-template/_templates/template1.html | 5 +++++ .../test-intl-template/_templates/template2.html | 5 +++++ tests/roots/test-intl-template/conf.py | 3 +++ tests/roots/test-intl-template/contents.rst | 0 tests/test_build_gettext.py | 15 +++++++++++++++ 5 files changed, 28 insertions(+) create mode 100644 tests/roots/test-intl-template/_templates/template1.html create mode 100644 tests/roots/test-intl-template/_templates/template2.html create mode 100644 tests/roots/test-intl-template/conf.py create mode 100644 tests/roots/test-intl-template/contents.rst diff --git a/tests/roots/test-intl-template/_templates/template1.html b/tests/roots/test-intl-template/_templates/template1.html new file mode 100644 index 000000000..f4b49f122 --- /dev/null +++ b/tests/roots/test-intl-template/_templates/template1.html @@ -0,0 +1,5 @@ +{% extends "layout.html" %} +{% block body %} +

{{ _('Template 1') }}

+

{%trans%}This is Template 1.{%endtrans%}

+{% endblock %} diff --git a/tests/roots/test-intl-template/_templates/template2.html b/tests/roots/test-intl-template/_templates/template2.html new file mode 100644 index 000000000..2a21069a6 --- /dev/null +++ b/tests/roots/test-intl-template/_templates/template2.html @@ -0,0 +1,5 @@ +{% extends "layout.html" %} +{% block body %} +

{{ _('Template 2') }}

+

{%trans%}This is Template 2.{%endtrans%}

+{% endblock %} diff --git a/tests/roots/test-intl-template/conf.py b/tests/roots/test-intl-template/conf.py new file mode 100644 index 000000000..1f4d84d07 --- /dev/null +++ b/tests/roots/test-intl-template/conf.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +templates_path = ['_templates'] diff --git a/tests/roots/test-intl-template/contents.rst b/tests/roots/test-intl-template/contents.rst new file mode 100644 index 000000000..e69de29bb diff --git a/tests/test_build_gettext.py b/tests/test_build_gettext.py index c14013f9a..179c90288 100644 --- a/tests/test_build_gettext.py +++ b/tests/test_build_gettext.py @@ -165,3 +165,18 @@ def test_gettext_template(app): result = (app.outdir / 'sphinx.pot').text(encoding='utf-8') assert "Welcome" in result assert "Sphinx %(version)s" in result + + +@pytest.mark.sphinx('gettext', testroot='intl-template') +def test_gettext_template_msgid_order_in_sphinxpot(app): + app.builder.build_all() + assert (app.outdir / 'sphinx.pot').isfile() + + result = (app.outdir / 'sphinx.pot').text(encoding='utf-8') + assert re.search( + ('msgid "Template 1".*' + 'msgid "This is Template 1\.".*' + 'msgid "Template 2".*' + 'msgid "This is Template 2\.".*'), + result, + flags=re.S)