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
1 changed files with 6 additions and 0 deletions

View File

@ -70,6 +70,7 @@ class DurationParseTests(unittest.TestCase):
def test_parse_postgresql_format(self):
test_values = (
('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)),
@ -137,10 +138,15 @@ class DurationParseTests(unittest.TestCase):
('P0.5D', timedelta(hours=12)),
('P0,5D', timedelta(hours=12)),
('PT5H', timedelta(hours=5)),
('-PT5H', timedelta(hours=-5)),
('PT5M', timedelta(minutes=5)),
('-PT5M', timedelta(minutes=-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)),
)
for source, expected in test_values:
with self.subTest(source=source):