comparison timedelta_tests.py @ 1:5fa902852779 default tip

add unit tests for timedelta function
author Dirk Olmes <dirk@xanthippe.ping.de>
date Sat, 10 Jan 2009 04:09:22 +0100
parents
children
comparison
equal deleted inserted replaced
0:78a59d65bfcc 1:5fa902852779
1
2 import unittest
3 from timedelta import timedelta
4 from datetime import time
5
6 class TimeDeltaTests(unittest.TestCase):
7 def testDeltaWrongArgumentOrder(self):
8 t1 = time(microsecond=4)
9 t2 = time(microsecond=5)
10 expected = time(microsecond=1)
11 self.assert_(expected == timedelta(t2, t1))
12
13 def testDeltaMicroseconds(self):
14 t1 = time(microsecond=4)
15 t2 = time(microsecond=5)
16 expected = time(microsecond=1)
17 self.assert_(expected == timedelta(t1, t2))
18
19 def testDeltaSeconds(self):
20 t1 = time(second=4)
21 t2 = time(second=5)
22 expected = time(second=1)
23 self.assert_(expected == timedelta(t1, t2))
24
25 def testDeltaMinutes(self):
26 t1 = time(minute=4)
27 t2 = time(minute=5)
28 expected = time(minute=1)
29 self.assert_(expected == timedelta(t1, t2))
30
31 def testDeltaHours(self):
32 t1 = time(hour=4)
33 t2 = time(hour=5)
34 expected = time(hour=1)
35 self.assert_(expected == timedelta(t1, t2))
36
37 def testDeltaMixed(self):
38 t1 = time(11, 32, 10)
39 t2 = time(11, 35, 30)
40 expected = time(minute=3, second=20)
41 self.assert_(expected == timedelta(t1, t2))
42
43 def testDeltaMax(self):
44 t1 = time(0, 0, 0, 0)
45 t2 = time(23, 59, 59, 999999)
46 expected = time(23, 59, 59, 999999)
47 self.assert_(expected == timedelta(t1, t2))
48
49 if __name__ == "__main__":
50 unittest.main()