Ejemplo n.º 1
0
 def test_mr_inscript2(self):
     trans = Transliterator('mr-inscript2')
     # In mr-inscript2, 'G-1' transliterates to U+200D ZERO WIDTH
     # JOINER ('\xe2\x80\x8d' in UTF-8 encoding):
     self.assertEqual(
         trans.transliterate(['j', 'd', 'G-1', '/']).encode('utf-8'),
         b'\xe0\xa4\xb0\xe0\xa5\x8d\xe2\x80\x8d\xe0\xa4\xaf')
Ejemplo n.º 2
0
 def test_si_wijesekera(self):
     trans = Transliterator('si-wijesekera')
     self.assertEqual(trans.transliterate(list('a')), '්')
     self.assertEqual(trans.transliterate(list('t')), 'එ')
     self.assertEqual(trans.transliterate(list('ta')), 'ඒ')
     self.assertEqual(
         trans.transliterate(list('vksIal kjSka ')), 'ඩනිෂ්ක නවීන් ')
Ejemplo n.º 3
0
 def test_non_existing_ime(self):
     # If initializing the transliterator fails, for example
     # because a non-existing input method was given as the
     # argument, a ValueError is raised:
     try:
         dummy_trans = Transliterator('ru-translitx')
     except ValueError:
         pass
     except Exception:
         # Something unexpected happened:
         self.assertTrue(False)
Ejemplo n.º 4
0
 def get_transliterator_or_skip(self, ime):
     try:
         sys.stderr.write('ime "%s" ... ' %ime)
         trans = Transliterator(ime)
     except ValueError as error:
         trans = None
         self.skipTest(error)
     except Exception as error:
         sys.stderr.write('Unexpected exception!')
         trans = None
         self.skipTest(error)
     return trans
Ejemplo n.º 5
0
 def test_hi_inscript2(self):
     trans = Transliterator('hi-inscript2')
     self.assertEqual(trans.transliterate([]), '')
     # Hindi-Inscript2 uses the AltGr key a lot, 'G-4' is the
     # MSymbol name for AltGr-4 and it transliterates to something
     # different than just '4':
     self.assertEqual(trans.transliterate(['4', 'G-4']), '४₹')
     self.assertEqual(trans.transliterate(['G-p']), 'ज़')
     # AltGr-3 ('G-3') is not used though in Hindi-Inscript2.
     # Therefore, 'G-3' transliterates just as 'G-3':
     self.assertEqual(trans.transliterate(['3', 'G-3']), '३G-3')
Ejemplo n.º 6
0
 def test_hi_itrans(self):
     trans = Transliterator('hi-itrans')
     self.assertEqual(trans.transliterate(list('namaste')), 'नमस्ते')
     self.assertEqual(trans.transliterate(list('. ')), '। ')
Ejemplo n.º 7
0
 def test_mr_itrans(self):
     trans = Transliterator('mr-itrans')
     self.assertEqual(trans.transliterate(list('praviN')), 'प्रविण्')
     self.assertEqual(trans.transliterate(list('namaste')), 'नमस्ते')
Ejemplo n.º 8
0
 def test_ru_translit(self):
     trans = Transliterator('ru-translit')
     self.assertEqual(trans.transliterate(list('y')), 'ы')
     self.assertEqual(trans.transliterate(list('yo')), 'ё')
     self.assertEqual(trans.transliterate(list('yo y')), 'ё ы')
Ejemplo n.º 9
0
 def test_NoIME(self):
     trans = Transliterator('NoIME')
     self.assertEqual(
         trans.transliterate(['a', 'b', 'c', 'C-c', 'G-4']),
         'abcC-cG-4')
Ejemplo n.º 10
0
 def test_t_latn_post(self):
     trans = Transliterator('t-latn-post')
     self.assertEqual(trans.transliterate(list('gru"n')), 'grün')