summaryrefslogtreecommitdiff
path: root/tests/regressiontests
diff options
context:
space:
mode:
authorJoseph Kocherhans <joseph@jkocherhans.com>2010-03-07 03:33:07 +0000
committerJoseph Kocherhans <joseph@jkocherhans.com>2010-03-07 03:33:07 +0000
commit5beb5f73722f7807f2be4e95b2fbe4a0e5dcd232 (patch)
tree7a1883997f66436db19d240c6e0db1ba8fb584e3 /tests/regressiontests
parent686dac03b7d6086730234512425f5e81baee7cbd (diff)
Fixed #12858. DateTime related widgets now handle custom formats properly in _has_changed. Thanks for the initial patch, camillo.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12698 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests')
-rw-r--r--tests/regressiontests/forms/widgets.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/regressiontests/forms/widgets.py b/tests/regressiontests/forms/widgets.py
index 4acaf831aa..d862f40b01 100644
--- a/tests/regressiontests/forms/widgets.py
+++ b/tests/regressiontests/forms/widgets.py
@@ -3,6 +3,7 @@ tests = r"""
>>> from django.forms import *
>>> from django.forms.widgets import RadioFieldRenderer
>>> from django.utils.safestring import mark_safe
+>>> from django.utils import formats
>>> import datetime
>>> import time
>>> import re
@@ -1149,6 +1150,14 @@ u'<input type="text" name="date" value="17/09/2007 12:51" />'
>>> w._has_changed(d, '17/09/2007 12:51')
False
+Make sure a custom format works with _has_changed. The hidden input will use
+format.localize_input to display the initial value.
+>>> data = datetime.datetime(2010, 3, 6, 12, 0, 0)
+>>> custom_format = '%d.%m.%Y %H:%M'
+>>> w = DateTimeInput(format=custom_format)
+>>> w._has_changed(formats.localize_input(data), data.strftime(custom_format))
+False
+
# DateInput ###################################################################
@@ -1182,6 +1191,15 @@ u'<input type="text" name="date" value="17/09/2007" />'
>>> w._has_changed(d, '17/09/2007')
False
+Make sure a custom format works with _has_changed. The hidden input will use
+format.localize_input to display the initial value.
+>>> data = datetime.date(2010, 3, 6)
+>>> custom_format = '%d.%m.%Y'
+>>> w = DateInput(format=custom_format)
+>>> w._has_changed(formats.localize_input(data), data.strftime(custom_format))
+False
+
+
# TimeInput ###################################################################
>>> w = TimeInput()
@@ -1217,6 +1235,15 @@ u'<input type="text" name="time" value="12:51" />'
>>> w._has_changed(t, '12:51')
False
+Make sure a custom format works with _has_changed. The hidden input will use
+format.localize_input to display the initial value.
+>>> data = datetime.time(13, 0)
+>>> custom_format = '%I:%M %p'
+>>> w = TimeInput(format=custom_format)
+>>> w._has_changed(formats.localize_input(data), data.strftime(custom_format))
+False
+
+
# SplitHiddenDateTimeWidget ###################################################
>>> from django.forms.widgets import SplitHiddenDateTimeWidget