summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2009-11-25 23:02:32 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2009-11-25 23:02:32 (GMT)
commitbe6859d877193004781c5b0b69f87b3ab5704ea1 (patch)
tree1a8448b965063fcea20203bfd949f215034155c0 /Lib
parent7d7aede558bc93196a40bd00fd857f57d00dd5bc (diff)
downloadcpython-be6859d877193004781c5b0b69f87b3ab5704ea1.zip
cpython-be6859d877193004781c5b0b69f87b3ab5704ea1.tar.gz
cpython-be6859d877193004781c5b0b69f87b3ab5704ea1.tar.bz2
Merged revisions 76529 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r76529 | antoine.pitrou | 2009-11-25 23:59:36 +0100 (mer., 25 nov. 2009) | 4 lines 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')
-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 8bf8420..d85217d 100644
--- a/Lib/test/test_datetime.py
+++ b/Lib/test/test_datetime.py
@@ -261,6 +261,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,