If you have time, add yr, mon, and
day instance variables,
modify the tick method to accomodate them.
Traditional Tests:
from clock import Clock
c1 = Clock(4, 7, 3)
print(c1)
print(c1.hr, c1.min, c1.sec)
c1.tick( )
print(c1)
c2 = Clock(4, 7, 59)
c2.tick
print(c2)
# Also create clocks c3 and c4 set to
# 04:59:59 and 23:59:59, respectively.
# Call the tick method for each of these
# clocks and print them to make sure that
# tick works correctly for all cases.
Unit Tests:
from clock import Clock
import unittest
class MyUnitTestClass(unittest.TestCase):
def test_1(self):
c1 = Clock(4, 7, 3)
self.assertEqual(str(c1), "04:07:03")
self.assertEqual(c1.hr, 4)
self.assertEqual(c1.min, 7)
self.assertEqual(c1.sec, 3)
c1.tick( )
self.assertEqual(str(c1), "04:07:04")
def test_2(self):
c2 = Clock(4, 7, 59)
self.assertEqual(str(c2), "04:07:59")
c1.tick( )
self.assertEqual(str(c2), "04:08:00")
# Also write test_3 and test_4
# methods that test clocks c3 and c4
# that start at 04:59:59 and
# 23:59:59, respectively.
if __name__ == '__main__':
unittest.main( )