Skip to content

Commit 85f6587

Browse files
committed
Test empty translation uses fallback
1 parent 41e8169 commit 85f6587

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/messages/test_mofile.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,26 @@ def test_more_plural_forms(self):
7171
catalog2.add(('Fuzz', 'Fuzzes'), ('', '', ''))
7272
buf = BytesIO()
7373
mofile.write_mo(buf, catalog2)
74+
75+
def test_empty_translation_with_fallback(self):
76+
catalog1 = Catalog(locale='fr_FR')
77+
catalog1.add(u'', '''\
78+
"Content-Type: text/plain; charset=utf-8\n"
79+
"Content-Transfer-Encoding: 8bit\n''')
80+
catalog1.add(u'Fuzz', '')
81+
buf1 = BytesIO()
82+
mofile.write_mo(buf1, catalog1)
83+
buf1.seek(0)
84+
catalog2 = Catalog(locale='fr')
85+
catalog2.add(u'', '''\
86+
"Content-Type: text/plain; charset=utf-8\n"
87+
"Content-Transfer-Encoding: 8bit\n''')
88+
catalog2.add(u'Fuzz', 'Flou')
89+
buf2 = BytesIO()
90+
mofile.write_mo(buf2, catalog2)
91+
buf2.seek(0)
92+
93+
translations = Translations(fp=buf1)
94+
translations.add_fallback(Translations(fp=buf2))
95+
96+
self.assertEqual(u'Flou', translations.ugettext('Fuzz'))

0 commit comments

Comments
 (0)