From 57d05f94c36fd88378e94470e13d1e1dc935748a Mon Sep 17 00:00:00 2001 From: starryrbs <1322096624@qq.com> Date: Mon, 21 Dec 2020 10:11:55 +0100 Subject: [PATCH] Added more assertions for parse_duration() with negative timedeltas. --- tests/utils_tests/test_dateparse.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/utils_tests/test_dateparse.py b/tests/utils_tests/test_dateparse.py index 844b7e4ab7..59dcab6b1c 100644 --- a/tests/utils_tests/test_dateparse.py +++ b/tests/utils_tests/test_dateparse.py @@ -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):