summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDavid Smith <smithdc@gmail.com>2020-04-06 12:23:32 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-04-07 06:20:43 +0200
commit5fbc0e07a92f192acfa6bc4b09c3732476eeefc6 (patch)
treea1be2baf60d9c7514b30be4557a669f0cdbd3b2a /tests
parentbe9dd70931b198aefdd012d05a80e8c746c7b732 (diff)
Completed test coverage for forms.DurationField.to_python().
Diffstat (limited to 'tests')
-rw-r--r--tests/forms_tests/field_tests/test_durationfield.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/forms_tests/field_tests/test_durationfield.py b/tests/forms_tests/field_tests/test_durationfield.py
index 2c2e17acd3..f5125aa571 100644
--- a/tests/forms_tests/field_tests/test_durationfield.py
+++ b/tests/forms_tests/field_tests/test_durationfield.py
@@ -20,6 +20,20 @@ class DurationFieldTest(FormFieldAssertionsMixin, SimpleTestCase):
datetime.timedelta(days=1, hours=1, minutes=15, seconds=30, milliseconds=300),
f.clean('1 1:15:30.3')
)
+ self.assertEqual(
+ datetime.timedelta(0, 10800),
+ f.clean(datetime.timedelta(0, 10800)),
+ )
+ msg = 'This field is required.'
+ with self.assertRaisesMessage(ValidationError, msg):
+ f.clean('')
+ msg = 'Enter a valid duration.'
+ with self.assertRaisesMessage(ValidationError, msg):
+ f.clean('not_a_time')
+
+ def test_durationfield_clean_not_required(self):
+ f = DurationField(required=False)
+ self.assertIsNone(f.clean(''))
def test_overflow(self):
msg = "The number of days must be between {min_days} and {max_days}.".format(