Exemplo n.º 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')))
Exemplo n.º 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')))
Exemplo n.º 3
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.")
Exemplo n.º 4
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')))
Exemplo n.º 5
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))
Exemplo n.º 6
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')))
Exemplo n.º 7
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')))
Exemplo n.º 8
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))
Exemplo n.º 9
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')))