summaryrefslogtreecommitdiff
path: root/tests/forms_tests
diff options
context:
space:
mode:
authorMichael Angeletti <michael@angelettigroup.com>2015-02-13 17:12:23 -0500
committerTim Graham <timograham@gmail.com>2015-02-14 07:37:18 -0500
commit8a21d250334f56845f255be5534b01d8c6eda314 (patch)
treecd5fc26aa22115d78c867a32df61df8b8594ad5d /tests/forms_tests
parent1791a7e75af8c9e7ca54425592379fd1f840fe88 (diff)
downloaddjango-8a21d250334f56845f255be5534b01d8c6eda314.tar.gz
Fixed #24339 -- Fixed crash with empty DurationField form field.
Diffstat (limited to 'tests/forms_tests')
-rw-r--r--tests/forms_tests/tests/test_fields.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/tests/forms_tests/tests/test_fields.py b/tests/forms_tests/tests/test_fields.py
index 1474698118..5f44811b93 100644
--- a/tests/forms_tests/tests/test_fields.py
+++ b/tests/forms_tests/tests/test_fields.py
@@ -48,6 +48,7 @@ from django.test import SimpleTestCase, ignore_warnings
from django.utils import formats, six, translation
from django.utils._os import upath
from django.utils.deprecation import RemovedInDjango20Warning
+from django.utils.duration import duration_string
try:
from PIL import Image
@@ -614,7 +615,7 @@ class FieldsTests(SimpleTestCase):
d = datetime.datetime(2006, 9, 17, 14, 30, 0)
self.assertFalse(f.has_changed(d, '2006 09 17 2:30 PM'))
- # RegexField ##################################################################
+ # DurationField ###########################################################
def test_durationfield_1(self):
f = DurationField()
@@ -642,6 +643,14 @@ class FieldsTests(SimpleTestCase):
str(f['duration'])
)
+ def test_durationfield_prepare_value(self):
+ field = DurationField()
+ td = datetime.timedelta(minutes=15, seconds=30)
+ self.assertEqual(field.prepare_value(td), duration_string(td))
+ self.assertIsNone(field.prepare_value(None))
+
+ # RegexField ##################################################################
+
def test_regexfield_1(self):
f = RegexField('^[0-9][A-F][0-9]$')
self.assertEqual('2A2', f.clean('2A2'))