Ejemplo n.º 1
0
 def test_get_all_languages_without_unknown(self):
     with bear_test_module():
         languages = get_all_languages()
         assert isinstance(languages, tuple)
         self.assertEqual(len(languages), LANGUAGE_COUNT)
         self.assertSetEqual({str(language)
                              for language in languages},
                             set(LANGUAGE_NAMES))
Ejemplo n.º 2
0
 def test_get_all_languages_without_unknown(self):
     with bear_test_module():
         languages = get_all_languages()
         assert isinstance(languages, tuple)
         self.assertEqual(len(languages), LANGUAGE_COUNT)
         self.assertSetEqual(
             {str(language) for language in languages},
             set(LANGUAGE_NAMES))
Ejemplo n.º 3
0
 def test_get_all_languages_with_unknown(self):
     with bear_test_module():
         languages = get_all_languages(include_unknown=True)
         language_names = LANGUAGE_NAMES.copy()
         language_names.append('Unknown')
         assert isinstance(languages, tuple)
         self.assertEqual(len(languages), LANGUAGE_COUNT + 1)
         self.assertSetEqual({str(language)
                              for language in languages},
                             set(language_names))
Ejemplo n.º 4
0
 def test_get_all_languages_with_unknown(self):
     with bear_test_module():
         languages = get_all_languages(include_unknown=True)
         language_names = LANGUAGE_NAMES.copy()
         language_names.append('Unknown')
         assert isinstance(languages, tuple)
         self.assertEqual(len(languages), LANGUAGE_COUNT + 1)
         self.assertSetEqual(
             {str(language) for language in languages},
             set(language_names))
Ejemplo n.º 5
0
 def __init__(cls, clsname, bases, clsattrs, *varargs, aspects=None,
              languages=None):
     """
     Initializes the ``.aspects`` dict and ``.languages`` array on new
     bear classes from the mapping and the sequence given to the
     keyword-only `aspects` and `languages` arguments, respectively.
     """
     type.__init__(cls, clsname, bases, clsattrs, *varargs)
     if aspects is not None:
         if languages is None:
             languages = get_all_languages(include_unknown=True)
         cls.languages = Languages(languages)
         cls.aspects = defaultdict(
             lambda: AspectList([]),
             ((k, AspectList(v, languages=cls.languages))
              for (k, v) in dict(aspects).items()))