<s> from tests import unittest <EOL> from tests . utils import MockClock <EOL> class MockClockTestCase ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . clock = MockClock ( ) <EOL> def test_advance_time ( self ) : <EOL> start_time = self . clock . time ( ) <EOL> self . clock . advance_time ( <NUM_LIT:20> ) <EOL> self . assertEquals ( <NUM_LIT:20> , self . clock . time ( ) - start_time ) <EOL> def test_later ( self ) : <EOL> invoked = [ <NUM_LIT:0> , <NUM_LIT:0> ] <EOL> def _cb0 ( ) : <EOL> invoked [ <NUM_LIT:0> ] = <NUM_LIT:1> <EOL> self . clock . call_later ( <NUM_LIT:10> , _cb0 ) <EOL> def _cb1 ( ) : <EOL> invoked [ <NUM_LIT:1> ] = <NUM_LIT:1> <EOL> self . clock . call_later ( <NUM_LIT:20> , _cb1 ) <EOL> self . assertFalse ( invoked [ <NUM_LIT:0> ] ) <EOL> self . clock . advance_time ( <NUM_LIT:15> ) <EOL> self . assertTrue ( invoked [ <NUM_LIT:0> ] ) <EOL> self . assertFalse ( invoked [ <NUM_LIT:1> ] ) <EOL> self . clock . advance_time ( <NUM_LIT:5> ) <EOL> self . assertTrue ( invoked [ <NUM_LIT:1> ] ) <EOL> def test_cancel_later ( self ) : <EOL> invoked = [ <NUM_LIT:0> , <NUM_LIT:0> ] <EOL> def _cb0 ( ) : <EOL> invoked [ <NUM_LIT:0> ] = <NUM_LIT:1> <EOL> t0 = self . clock . call_later ( <NUM_LIT:10> , _cb0 ) <EOL> def _cb1 ( ) : <EOL> invoked [ <NUM_LIT:1> ] = <NUM_LIT:1> <EOL> self . clock . call_later ( <NUM_LIT:20> , _cb1 ) <EOL> self . clock . cancel_call_later ( t0 ) <EOL> self . clock . advance_time ( <NUM_LIT:30> ) <EOL> self . assertFalse ( invoked [ <NUM_LIT:0> ] ) <EOL> self . assertTrue ( invoked [ <NUM_LIT:1> ] ) </s>
