1
0
mirror of https://github.com/django/django.git synced 2025-10-26 15:16:09 +00:00

[1.8.x] Fixed #24897 -- Allowed using choices longer than 1 day with DurationField

Backport of 262d4db8c4 from master
This commit is contained in:
zauddelig
2015-06-02 11:08:41 +02:00
committed by Tim Graham
parent 9d83de8ff3
commit 7f92b6e576
3 changed files with 18 additions and 1 deletions

View File

@@ -51,6 +51,20 @@ class DateParseTests(unittest.TestCase):
class DurationParseTests(unittest.TestCase):
def test_parse_python_format(self):
timedeltas = [
timedelta(days=4, minutes=15, seconds=30, milliseconds=100), # fractions of seconds
timedelta(hours=10, minutes=15, seconds=30), # hours, minutes, seconds
timedelta(days=4, minutes=15, seconds=30), # multiple days
timedelta(days=1, minutes=00, seconds=00), # single day
timedelta(days=-4, minutes=15, seconds=30), # negative durations
timedelta(minutes=15, seconds=30), # minute & seconds
timedelta(seconds=30), # seconds
]
for delta in timedeltas:
self.assertEqual(parse_duration(format(delta)), delta)
def test_seconds(self):
self.assertEqual(parse_duration('30'), timedelta(seconds=30))