summaryrefslogtreecommitdiff
path: root/tests/messages
diff options
context:
space:
mode:
authorXavier Fernandez <xavier.fernandez@polyconseil.fr>2017-03-21 16:36:56 +0100
committerXavier Fernandez <xavier.fernandez@polyconseil.fr>2017-03-21 16:46:28 +0100
commit1290a5d5c8f62069d93a9bbec3c7f98b57b36e3f (patch)
tree1dbc7db5671ef371653d8d39f1e3b67254e85d96 /tests/messages
parent57d47e0d69217c2fa5aec3a072a4972823669db3 (diff)
downloadbabel-1290a5d5c8f62069d93a9bbec3c7f98b57b36e3f.tar.gz
When msgid are equal, sort according to msgctxt
Fix #481
Diffstat (limited to 'tests/messages')
-rw-r--r--tests/messages/test_pofile.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/messages/test_pofile.py b/tests/messages/test_pofile.py
index cef6913..ebf9702 100644
--- a/tests/messages/test_pofile.py
+++ b/tests/messages/test_pofile.py
@@ -680,6 +680,41 @@ msgstr[0] "Voh"
msgstr[1] "Voeh"''' in value
assert value.find(b'msgid ""') < value.find(b'msgid "bar"') < value.find(b'msgid "foo"')
+ def test_sorted_po_context(self):
+ catalog = Catalog()
+ catalog.add((u'foo', u'foos'), (u'Voh', u'Voeh'),
+ locations=[('main.py', 1)],
+ context='there')
+ catalog.add((u'foo', u'foos'), (u'Voh', u'Voeh'),
+ locations=[('main.py', 1)])
+ catalog.add((u'foo', u'foos'), (u'Voh', u'Voeh'),
+ locations=[('main.py', 1)],
+ context='here')
+ buf = BytesIO()
+ pofile.write_po(buf, catalog, sort_output=True)
+ value = buf.getvalue().strip()
+ # We expect the foo without ctx, followed by "here" foo and "there" foo
+ assert b'''\
+#: main.py:1
+msgid "foo"
+msgid_plural "foos"
+msgstr[0] "Voh"
+msgstr[1] "Voeh"
+
+#: main.py:1
+msgctxt "here"
+msgid "foo"
+msgid_plural "foos"
+msgstr[0] "Voh"
+msgstr[1] "Voeh"
+
+#: main.py:1
+msgctxt "there"
+msgid "foo"
+msgid_plural "foos"
+msgstr[0] "Voh"
+msgstr[1] "Voeh"''' in value
+
def test_file_sorted_po(self):
catalog = Catalog()
catalog.add(u'bar', locations=[('utils.py', 3)])