Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ........FF........................................
- ======================================================================
- FAIL: test_clocks_a_minute_apart (__main__.ClockTest)
- ----------------------------------------------------------------------
- Traceback (most recent call last):
- File "clock_test.py", line 119, in test_clocks_a_minute_apart
- self.assertNotEqual(Clock(15, 36), Clock(15, 37))
- AssertionError: <clock.Clock object at 0x7faf3d647be0> == <clock.Clock object at 0x7faf3d647ac8>
- ======================================================================
- FAIL: test_clocks_an_hour_apart (__main__.ClockTest)
- ----------------------------------------------------------------------
- Traceback (most recent call last):
- File "clock_test.py", line 122, in test_clocks_an_hour_apart
- self.assertNotEqual(Clock(14, 37), Clock(15, 37))
- AssertionError: <clock.Clock object at 0x7faf3d647be0> == <clock.Clock object at 0x7faf3d647c18>
- ----------------------------------------------------------------------
- Ran 50 tests in 0.003s
- FAILED (failures=2)
- #
- # Skeleton file for the Python "Clock" exercise.
- #
- class Clock(object):
- def __init__(self, hours, minutes):
- self.hours = hours
- self.minutes = minutes
- self.fix()
- def __str__(self):
- return '{0:02d}:{1:02d}'.format(self.hours, self.minutes)
- def __eq__(self, other):
- return '{0:02d}:{1:02d}'.format(self.hours, self.minutes)
- def add(self, increment):
- self.increment = increment
- self.minutes += self.increment
- self.fix()
- return '{0:02d}:{1:02d}'.format(self.hours, self.minutes)
- def fix(self):
- if self.minutes > 59 or self.minutes < 0:
- self.hours += self.minutes // 60
- self.minutes = self.minutes % 60
- elif self.minutes == 60:
- self.hours += 1
- self.minutes = 0
- else:
- self.minutes = self.minutes
- if self.hours > 24 or self.hours < -24:
- self.hours = self.hours % 24
- elif self.hours < 0:
- self.hours += 24
- elif self.hours == 24 or self.hours == (-24):
- self.hours = 0
- else:
- self.hours = self.hours
Advertisement
Add Comment
Please, Sign In to add comment