summaryrefslogtreecommitdiff
path: root/tests/forms_tests/widget_tests/test_select.py
diff options
context:
space:
mode:
authorJon Dufresne <jon.dufresne@gmail.com>2017-04-21 09:14:40 -0700
committerTim Graham <timograham@gmail.com>2017-04-21 12:29:20 -0400
commit1442e299839febf9599e98dff2e6bb6da24df0ac (patch)
tree83196f85e0abb1d567cbc386714c3d5674fee789 /tests/forms_tests/widget_tests/test_select.py
parentc9d933ba999ef0c3b37045335715d93e92ddb279 (diff)
[1.11.x] Fixed #28075 -- Prevented ChoiceWidget from localizing option values.
Backport of 581879a510e58841e5780a5d1fdb4995733d2036 from master
Diffstat (limited to 'tests/forms_tests/widget_tests/test_select.py')
-rw-r--r--tests/forms_tests/widget_tests/test_select.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/forms_tests/widget_tests/test_select.py b/tests/forms_tests/widget_tests/test_select.py
index d2660ea787..96e62bf189 100644
--- a/tests/forms_tests/widget_tests/test_select.py
+++ b/tests/forms_tests/widget_tests/test_select.py
@@ -2,8 +2,10 @@
from __future__ import unicode_literals
import copy
+import datetime
from django.forms import Select
+from django.test import override_settings
from django.utils.safestring import mark_safe
from .base import WidgetTest
@@ -221,6 +223,34 @@ class SelectTest(WidgetTest):
</select>"""
))
+ @override_settings(USE_L10N=True, USE_THOUSAND_SEPARATOR=True)
+ def test_doesnt_localize_option_value(self):
+ choices = [
+ (1, 'One'),
+ (1000, 'One thousand'),
+ (1000000, 'One million'),
+ ]
+ html = """
+ <select name="number">
+ <option value="1">One</option>
+ <option value="1000">One thousand</option>
+ <option value="1000000">One million</option>
+ </select>
+ """
+ self.check_html(self.widget(choices=choices), 'number', None, html=html)
+
+ choices = [
+ (datetime.time(0, 0), 'midnight'),
+ (datetime.time(12, 0), 'noon'),
+ ]
+ html = """
+ <select name="time">
+ <option value="00:00:00">midnight</option>
+ <option value="12:00:00">noon</option>
+ </select>
+ """
+ self.check_html(self.widget(choices=choices), 'time', None, html=html)
+
def test_options(self):
options = list(self.widget(choices=self.beatles).options(
'name', ['J'], attrs={'class': 'super'},