    def test_clock(self, mock_datetime):
        """
        Check that Clock works.
        """
        # Check that Clock updates every second.
        screen = MagicMock(spec=Screen, colours=8, unicode_aware=False)
        mock_datetime.now.return_value = datetime
        mock_datetime.side_effect = lambda *args, **kw: datetime(*args, **kw)
        canvas = Canvas(screen, 10, 40, 0, 0)
        effect = Clock(canvas, 10, 5, 5)
        effect.reset()
        self.assert_blank(canvas)
        my_buffer = [[(32, 7, 0, 0) for _ in range(40)] for _ in range(10)]

        # Set a time for the next update and check it is drawn.
        mock_datetime.now.return_value = \
            datetime(1900, 1, 2, 3, 59, 40)
        effect.update(0)
        mock_datetime.now.assert_called()
        self.assertEqual(self.check_canvas(
            canvas,
            my_buffer,
            lambda value: self.assertLess(value[0], 129)),
            True)

        # Check redrawing with the same time has no effect.
        mock_datetime.now.reset_mock()
        mock_datetime.now.return_value = \
            datetime(1900, 1, 2, 3, 59, 40)
        effect.update(1)
        mock_datetime.now.assert_called()
        self.assertEqual(self.check_canvas(
            canvas,
            my_buffer,
            lambda value: self.assertLess(value[0], 129)),
            False)

        # Check a new time results in an update.
        mock_datetime.now.reset_mock()
        mock_datetime.now.return_value = \
            datetime(1900, 1, 2, 3, 59, 41)
        effect.update(2)
        mock_datetime.now.assert_called()
        self.assertEqual(self.check_canvas(
            canvas,
            my_buffer,
            lambda value: self.assertLess(value[0], 129)),
            True)

        # Check there is no stop frame by default.
        self.assertEqual(effect.stop_frame, 0)

        # This effect should ignore events.
        event = object()
        self.assertEqual(event, effect.process_event(event))
Check that Clock works.
tests/test_effects.py