Ticket #18509: tests.py

File tests.py, 802 bytes (added by Serge Spaolonzi, 12 years ago)
Line 
1from django import forms
2from django.test import TestCase
3from django.utils import translation
4from django.core.exceptions import ValidationError
5
6
7class LocalizationTests(TestCase):
8 def test_localization(self):
9 with translation.override('es'):
10 with self.settings(USE_L10N=True):
11 #Non Localized Field
12 non_localized_field = forms.DecimalField(localize=False)
13 with self.assertRaises(ValidationError):
14 non_localized_field.to_python("234,23")
15
16 #Localized Decimal Field
17 localized_field = forms.DecimalField(localize=True)
18 with self.assertRaises(ValidationError):
19 localized_field.to_python("234.23")
Back to Top