diff options
| author | Michael Angeletti <michael@angelettigroup.com> | 2015-02-13 17:12:23 -0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-02-14 07:38:20 -0500 |
| commit | 2e6d8e51db7c469ef32c7d00ff5aa7e68237f5f1 (patch) | |
| tree | 6375afc5741151b970b726db51bf47d45d092279 /tests/forms_tests | |
| parent | 0f3eb8260b251a15c57f577fb33baad88b284942 (diff) | |
[1.8.x] Fixed #24339 -- Fixed crash with empty DurationField form field.
Backport of 8a21d250334f56845f255be5534b01d8c6eda314 from master
Diffstat (limited to 'tests/forms_tests')
| -rw-r--r-- | tests/forms_tests/tests/test_fields.py | 11 |
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 98c65b4a22..1d1f8febda 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 @@ -607,7 +608,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() @@ -635,6 +636,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')) |
