summaryrefslogtreecommitdiff
path: root/Lib/test/test_datetime.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2009-11-25 22:59:36 +0000
committerAntoine Pitrou <solipsis@pitrou.net>2009-11-25 22:59:36 +0000
commitbcfaf8007d8d14e3a6e65d13ad693b4874688cab (patch)
tree1423462840d4c68918760c667ad79f81e0c611ef /Lib/test/test_datetime.py
parent0d9f61a5437463c143a275a7b6bda257160dad76 (diff)
downloadcpython-git-bcfaf8007d8d14e3a6e65d13ad693b4874688cab.tar.gz
Issue #5788: `datetime.timedelta` objects get a new `total_seconds()` method returning
the total number of seconds in the duration. Patch by Brian Quinlan.
Diffstat (limited to 'Lib/test/test_datetime.py')
-rw-r--r--Lib/test/test_datetime.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_datetime.py b/Lib/test/test_datetime.py
index ad36398598..1fb3d1bf20 100644
--- a/Lib/test/test_datetime.py
+++ b/Lib/test/test_datetime.py
@@ -266,6 +266,13 @@ class TestTimeDelta(HarmlessMixedComparison, unittest.TestCase):
self.assertEqual(td.seconds, seconds)
self.assertEqual(td.microseconds, us)
+ def test_total_seconds(self):
+ td = timedelta(days=365)
+ self.assertEqual(td.total_seconds(), 31536000.0)
+ for total_seconds in [123456.789012, -123456.789012, 0.123456, 0, 1e6]:
+ td = timedelta(seconds=total_seconds)
+ self.assertEqual(td.total_seconds(), total_seconds)
+
def test_carries(self):
t1 = timedelta(days=100,
weeks=-7,