예제 #1
0
    def assertRoundtrips(self, bcp47_code, new_bcp47_code=None):
        lc = LanguageCode(bcp47_code, 'bcp47')
        new_bcp47_code = new_bcp47_code or bcp47_code

        self.assertEqual(new_bcp47_code, lc.encode('bcp47'),
                        "BCP47 code '%s' did not round trip to '%s' properly (it encoded to '%s' instead)!"
                         % (bcp47_code, new_bcp47_code, lc.encode('bcp47')))
예제 #2
0
    def assertRoundtrips(self, bcp47_code, new_bcp47_code=None):
        lc = LanguageCode(bcp47_code, 'bcp47')
        new_bcp47_code = new_bcp47_code or bcp47_code

        self.assertEqual(
            new_bcp47_code, lc.encode('bcp47'),
            "BCP47 code '%s' did not round trip to '%s' properly (it encoded to '%s' instead)!"
            % (bcp47_code, new_bcp47_code, lc.encode('bcp47')))
예제 #3
0
    def test_aliases(self):
        lc = LanguageCode('bm', 'iso-639-1')
        aliases = lc.aliases()

        self.assertIn('iso-639-1', aliases,
                      "Alias not found.")
        self.assertIn('unisubs', aliases,
                      "Alias not found.")

        self.assertEqual('bm', aliases['iso-639-1'],
                         'Incorrect alias.')
        self.assertEqual('bam', aliases['unisubs'],
                         'Incorrect alias.')
예제 #4
0
    def test_encode(self):
        lc = LanguageCode('en', 'iso-639-1')

        self.assertEqual('en', lc.encode('iso-639-1'),
                         "Incorrect encoded value.")

        lc = LanguageCode('bm', 'iso-639-1')

        self.assertEqual('bm', lc.encode('iso-639-1'),
                         "Incorrect encoded value.")

        self.assertEqual('bam', lc.encode('unisubs'),
                         "Incorrect encoded value.")
예제 #5
0
 def assertEncodesAs(self, unisubs_code, bcp47_code):
     lc = LanguageCode(unisubs_code, 'unisubs')
     self.assertEqual(
         bcp47_code, lc.encode('bcp47'),
         "Unisubs code '%s' did not encode to BCP47 code '%s' (it encoded to '%s' instead)!"
         % (unisubs_code, bcp47_code, lc.encode('bcp47')))
예제 #6
0
 def assertLossilyDecodesAs(self, bcp47_code, unilangs_code):
     lc = LanguageCode(bcp47_code, 'bcp47-lossy')
     self.assertEqual(
         unilangs_code, lc.encode('unisubs'),
         "BCP47 code '%s' did not lossily decode to unilangs code '%s'!" %
         (bcp47_code, unilangs_code))
예제 #7
0
 def assertDecodesAs(self, bcp47_code, unilangs_code):
     lc = LanguageCode(bcp47_code, 'bcp47')
     self.assertEqual(
         unilangs_code, lc.encode('unisubs'),
         "BCP47 code '%s' did not decode to unilangs code '%s' (it decoded to '%s')!"
         % (bcp47_code, unilangs_code, lc.encode('unisubs')))
예제 #8
0
 def assertEncodesAs(self, unisubs_code, bcp47_code):
     lc = LanguageCode(unisubs_code, 'unisubs')
     self.assertEqual(bcp47_code, lc.encode('bcp47'),
                     "Unisubs code '%s' did not encode to BCP47 code '%s' (it encoded to '%s' instead)!"
                      % (unisubs_code, bcp47_code, lc.encode('bcp47')))
예제 #9
0
 def assertLossilyDecodesAs(self, bcp47_code, unilangs_code):
     lc = LanguageCode(bcp47_code, 'bcp47-lossy')
     self.assertEqual(unilangs_code, lc.encode('unisubs'),
                      "BCP47 code '%s' did not lossily decode to unilangs code '%s'!"
                      % (bcp47_code, unilangs_code))
예제 #10
0
 def assertDecodesAs(self, bcp47_code, unilangs_code):
     lc = LanguageCode(bcp47_code, 'bcp47')
     self.assertEqual(unilangs_code, lc.encode('unisubs'),
                      "BCP47 code '%s' did not decode to unilangs code '%s' (it decoded to '%s')!"
                      % (bcp47_code, unilangs_code, lc.encode('unisubs')))