1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Added more assertions for parse_duration() with negative timedeltas.

This commit is contained in:
starryrbs 2020-12-21 10:11:55 +01:00 committed by Mariusz Felisiak
parent 577f2338f1
commit 57d05f94c3

View File

@ -70,6 +70,7 @@ class DurationParseTests(unittest.TestCase):
def test_parse_postgresql_format(self): def test_parse_postgresql_format(self):
test_values = ( test_values = (
('1 day', timedelta(1)), ('1 day', timedelta(1)),
('-1 day', timedelta(-1)),
('1 day 0:00:01', timedelta(days=1, seconds=1)), ('1 day 0:00:01', timedelta(days=1, seconds=1)),
('1 day -0:00:01', timedelta(days=1, seconds=-1)), ('1 day -0:00:01', timedelta(days=1, seconds=-1)),
('-1 day -0:00:01', timedelta(days=-1, seconds=-1)), ('-1 day -0:00:01', timedelta(days=-1, seconds=-1)),
@ -137,10 +138,15 @@ class DurationParseTests(unittest.TestCase):
('P0.5D', timedelta(hours=12)), ('P0.5D', timedelta(hours=12)),
('P0,5D', timedelta(hours=12)), ('P0,5D', timedelta(hours=12)),
('PT5H', timedelta(hours=5)), ('PT5H', timedelta(hours=5)),
('-PT5H', timedelta(hours=-5)),
('PT5M', timedelta(minutes=5)), ('PT5M', timedelta(minutes=5)),
('-PT5M', timedelta(minutes=-5)),
('PT5S', timedelta(seconds=5)), ('PT5S', timedelta(seconds=5)),
('-PT5S', timedelta(seconds=-5)),
('PT0.000005S', timedelta(microseconds=5)), ('PT0.000005S', timedelta(microseconds=5)),
('PT0,000005S', timedelta(microseconds=5)), ('PT0,000005S', timedelta(microseconds=5)),
('-PT0.000005S', timedelta(microseconds=-5)),
('-PT0,000005S', timedelta(microseconds=-5)),
) )
for source, expected in test_values: for source, expected in test_values:
with self.subTest(source=source): with self.subTest(source=source):