diff options
| author | Srinivas Reddy Thatiparthy <thatiparthysreenivas@gmail.com> | 2017-08-08 20:32:08 +0530 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-10-25 18:05:13 -0400 |
| commit | 55b5393bd235aa6c55ea9a7da6f0e8b75b204084 (patch) | |
| tree | 6cb753f4df8ecbb339ed3c462530bff21edbc244 /tests/forms_tests | |
| parent | 81e357a7e19f35235cc998459a10213532727d4e (diff) | |
Fixed #28474 -- Made DurationField raise ValidationError for inputs that raised OverflowError.
Diffstat (limited to 'tests/forms_tests')
| -rw-r--r-- | tests/forms_tests/field_tests/test_durationfield.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/forms_tests/field_tests/test_durationfield.py b/tests/forms_tests/field_tests/test_durationfield.py index ce578ff82f..4eac37c102 100644 --- a/tests/forms_tests/field_tests/test_durationfield.py +++ b/tests/forms_tests/field_tests/test_durationfield.py @@ -1,5 +1,6 @@ import datetime +from django.core.exceptions import ValidationError from django.forms import DurationField from django.test import SimpleTestCase from django.utils.duration import duration_string @@ -19,6 +20,17 @@ class DurationFieldTest(FormFieldAssertionsMixin, SimpleTestCase): f.clean('1 1:15:30.3') ) + def test_overflow(self): + msg = "The number of days must be between {min_days} and {max_days}.".format( + min_days=datetime.timedelta.min.days, + max_days=datetime.timedelta.max.days, + ) + f = DurationField() + with self.assertRaisesMessage(ValidationError, msg): + f.clean('1000000000 00:00:00') + with self.assertRaisesMessage(ValidationError, msg): + f.clean('-1000000000 00:00:00') + def test_durationfield_render(self): self.assertWidgetRendersTo( DurationField(initial=datetime.timedelta(hours=1)), |
