summaryrefslogtreecommitdiff
path: root/oslo_i18n/tests/test_message.py
diff options
context:
space:
mode:
Diffstat (limited to 'oslo_i18n/tests/test_message.py')
-rw-r--r--oslo_i18n/tests/test_message.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/oslo_i18n/tests/test_message.py b/oslo_i18n/tests/test_message.py
index 559e5d0..629238a 100644
--- a/oslo_i18n/tests/test_message.py
+++ b/oslo_i18n/tests/test_message.py
@@ -616,6 +616,21 @@ class MessageTestCase(test_base.BaseTestCase):
self.assertEqual(zh_translation, msg.translate('zh'))
self.assertEqual(fr_translation, msg.translate('fr'))
+ def test_translate_with_dict(self):
+ msg = _message.Message('abc')
+ # This dict is what you get back from str.maketrans('abc', 'xyz')
+ # We can't actually call that here because it doesn't exist on py2
+ # and the string.maketrans that does behaves differently.
+ self.assertEqual('xyz', msg.translate({97: 120, 98: 121, 99: 122}))
+
+ def test_translate_with_list(self):
+ msg = _message.Message('abc')
+ table = [six.unichr(x) for x in range(128)]
+ table[ord('a')] = 'b'
+ table[ord('b')] = 'c'
+ table[ord('c')] = 'd'
+ self.assertEqual('bcd', msg.translate(table))
+
class TranslateMsgidTest(test_base.BaseTestCase):