1 | from django import forms
|
---|
2 | from django.test import TestCase
|
---|
3 | from django.utils import translation
|
---|
4 | from django.core.exceptions import ValidationError
|
---|
5 |
|
---|
6 |
|
---|
7 | class 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")
|
---|