Example #1
0
 def test_with_country(self):
     self.assertTrue(
         Language('Portuguese (BR)').country == Country('Brazil'))
     self.assertTrue(Language('pt_BR').country == Country('Brazil'))
     self.assertTrue(Language('fr - France').country == Country('France'))
     self.assertTrue(
         Language('fra', country='FR').country == Country('France'))
     self.assertTrue(
         Language('fra', country=Country('FRA')).country == Country(
             'France'))
Example #2
0
 def test_attrs(self):
     language = Language('French')
     self.assertTrue(language.alpha2 == 'fr')
     self.assertTrue(language.alpha3 == 'fre')
     self.assertTrue(language.terminologic == 'fra')
     self.assertTrue(language.name == 'French')
     self.assertTrue(language.french_name == u'français')
Example #3
0
 def test_external_subtitles(self):
     results = [
         s for s in scan(test_dir)[0][1] if isinstance(s, ExternalSubtitle)
     ]
     self.assertTrue(len(results) == 3)
     for l in ('fre', 'eng', 'und'):
         self.assertTrue(any([s.language == Language(l) for s in results]))
Example #4
0
 def test_embedded_subtitles(self):
     results = [
         s for s in scan(test_dir)[0][1] if isinstance(s, EmbeddedSubtitle)
     ]
     self.assertTrue(len(results) == 8)
     for l in ('fre', 'eng', 'ita', 'spa', 'hun', 'ger', 'jpn', 'und'):
         self.assertTrue(any([s.language == Language(l) for s in results]))
Example #5
0
 def test_list_index(self):
     languages = [Language('fr'), Language('en-US'), Language('en-GB')]
     self.assertTrue(languages.index(Language('fr')) == 0)
     self.assertTrue(languages.index(Language('en-US')) == 1)
     self.assertTrue(languages.index(Language('en-GB')) == 2)
     with self.assertRaises(ValueError):
         languages.index(Language('fr-BE'))
Example #6
0
 def test_list_contains(self):
     languages = list(
         [Language('fr'),
          Language('en-US'),
          Language('en-GB')])
     self.assertTrue(Language('fr') in languages)
     self.assertTrue(Language('en-US') in languages)
     self.assertTrue(Language('en') not in languages)
     self.assertTrue(Language('fr-BE') not in languages)
Example #7
0
 def test_eq(self):
     language = Language('French')
     self.assertTrue(language == Language('fr'))
     self.assertTrue(language == Language('fre'))
     self.assertTrue(language == Language('fra'))
     self.assertTrue(language == Language('Français'))
Example #8
0
 def test_language_set_intersect(self):
     languages = language_set(['fr', 'en-US', 'en-GB'])
     self.assertTrue(len(languages & language_set([Language('en')])) == 2)
     self.assertTrue(len(language_set([Language('en')]) & languages) == 2)
     self.assertTrue(len(languages & language_set([Language('fr')])) == 1)
Example #9
0
 def test_language_set_contains(self):
     languages = language_set(['fr', 'en-US', 'en-GB'])
     self.assertTrue(Language('fr') in languages)
     self.assertTrue(Language('en-US') in languages)
     self.assertTrue(Language('en') not in languages)
     self.assertTrue(Language('fr-BE') in languages)
Example #10
0
 def test_language_list_index(self):
     languages = language_list(['fr', 'en-US', 'en-GB'])
     self.assertTrue(languages.index(Language('fr')) == 0)
     self.assertTrue(languages.index(Language('en-US')) == 1)
     self.assertTrue(languages.index(Language('en-GB')) == 2)
     self.assertTrue(languages.index(Language('fr-BE')) == 0)
Example #11
0
 def test_missing(self):
     with self.assertRaises(ValueError):
         Language('zzz')
Example #12
0
 def test_hash(self):
     self.assertTrue(hash(Language('French')) == hash('fre'))
Example #13
0
 def test_ne_with_country(self):
     self.assertTrue(Language('Portuguese') != Language('Portuguese (BR)'))
     self.assertTrue(Language('English (US)') != Language('English (GB)'))
Example #14
0
 def test_eq_with_country(self):
     self.assertTrue(
         Language('Portuguese (BR)') == Language('Portuguese - Brazil'))
     self.assertTrue(Language('English') == Language('en'))
Example #15
0
 def test_in(self):
     self.assertTrue(
         Language('Portuguese (BR)') in Language('Portuguese - Brazil'))
     self.assertTrue(Language('Portuguese (BR)') in Language('Portuguese'))
     self.assertTrue(
         Language('Portuguese') not in Language('Portuguese (BR)'))
Example #16
0
 def test_ne(self):
     self.assertTrue(Language('French') != Language('en'))