def test_existing_accented_custom_list(self): self.assertEqual(_get_probe_language(['en-gb']), ['en-gb'])
def test_invalid_custom_list(self): with self.assertRaises(ValueError) as error: _get_probe_language(['xx']) self.assertEqual(error.exception.args[0], '`xx` is not a supported language.')
def test_existing_accented_custom_str(self): self.assertEqual(_get_probe_language('en-gb'), 'en-gb')
def test_unaccented_custom_list(self): self.assertEqual(_get_probe_language(['en']), ['en'])
def test_unaccented_custom_str(self): self.assertEqual(_get_probe_language('en'), 'en')
def test_existing_accented_active(self): self.assertEqual(_get_probe_language(), 'en-gb')
def test_unaccented_active(self): self.assertEqual(_get_probe_language(), 'en')
def __call__(self, lang=None): """Specialize the `TQ` for some language(s).""" obj = copy.deepcopy(self) obj.lang = _get_probe_language(lang) return obj
def probe(self, lang=None): """Probe the `TranslatableQuerySet` in some language(s).""" clone = self.all() clone._trans_prob = _get_probe_language(lang) return clone