#NEWLINE# def testPeriodic( self ) : #NEWLINE# #INDENT# sched = schedule . Schedule ( ) #NEWLINE# i = [ 0 ] #NEWLINE# def inc( ) : #NEWLINE# #INDENT# i [ 0 ] += 1 #NEWLINE# #UNINDENT# n = sched . addPeriodicEvent ( inc , 1 , name = 'test_periodic' ) #NEWLINE# time . sleep ( 0.6 ) #NEWLINE# sched . run ( ) #NEWLINE# self . assertEqual ( inc [ 0 ] , 1 ) #NEWLINE# time . sleep ( 0.6 ) #NEWLINE# sched . run ( ) #NEWLINE# self . assertEqual ( i [ 0 ] , 2 ) #NEWLINE# time . sleep ( 0.6 ) #NEWLINE# sched . run ( ) #NEWLINE# self . assertEqual ( i [ 0 ] , 2 ) #NEWLINE# time . sleep ( 0.6 ) #NEWLINE# sched . run ( ) #NEWLINE# self . assertEqual ( i [ 0 ] , 3 ) #NEWLINE# sched . removePeriodicEvent ( n ) #NEWLINE# time . sleep ( 1 ) #NEWLINE# sched . run ( ) #NEWLINE# self . assertEqual ( i [ 0 ] , 3 )