mirror of
https://github.com/django/django.git
synced 2024-12-23 01:25:58 +00:00
Completed test coverage for forms.DurationField.to_python().
This commit is contained in:
parent
be9dd70931
commit
5fbc0e07a9
@ -20,6 +20,20 @@ class DurationFieldTest(FormFieldAssertionsMixin, SimpleTestCase):
|
|||||||
datetime.timedelta(days=1, hours=1, minutes=15, seconds=30, milliseconds=300),
|
datetime.timedelta(days=1, hours=1, minutes=15, seconds=30, milliseconds=300),
|
||||||
f.clean('1 1:15:30.3')
|
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):
|
def test_overflow(self):
|
||||||
msg = "The number of days must be between {min_days} and {max_days}.".format(
|
msg = "The number of days must be between {min_days} and {max_days}.".format(
|
||||||
|
Loading…
Reference in New Issue
Block a user