def test_defaults(self): # Test with the default language form = self._common_test('This field is required.', {}) # Make sure we have a gettext translations context self.assertNotEqual(form.a.gettext(''), '') form = self._common_test('This field is required.', {}, self.F2) assert form._get_translations() is None assert form.LANGUAGES is False self.assertEqual(form.a.gettext(''), '')
def test_defaults(self): # Test with the default language form = self._common_test('This field is required.', {}) # Make sure we have a gettext translations context self.assertNotEqual(form.a.gettext(''), '') form = self._common_test('This field is required.', {}, self.F2) assert form._get_translations() is None assert form.meta.locales is False self.assertEqual(form.a.gettext(''), '')
def test_form(self): tcache = i18n_form.translations_cache tcache.clear() form = self.F() assert ('en_US', 'en') in tcache assert form._get_translations() is tcache[('en_US', 'en')] assert not form.validate() self.assertEqual(form.a.errors[0], 'This field is required.') form = self.F(LANGUAGES=['es']) assert ('es', ) in tcache self.assertEqual(len(tcache), 2) assert not form.validate() self.assertEqual(form.a.errors[0], 'Este campo es obligatorio.')
def test_form(self): tcache = i18n_form.translations_cache tcache.clear() form = self.F() assert ('en_US', 'en') in tcache assert form._get_translations() is tcache[('en_US', 'en')] assert not form.validate() self.assertEqual(form.a.errors[0], 'This field is required.') form = self.F(LANGUAGES=['es']) assert ('es', ) in tcache self.assertEquals(len(tcache), 2) assert not form.validate() self.assertEqual(form.a.errors[0], 'Este campo es obligatorio.')