<s> import sys <EOL> import unittest <EOL> import pyglet <EOL> __noninteractive = True <EOL> if sys . platform in ( '<STR_LIT:win32>' , '<STR_LIT>' ) : <EOL> from time import clock as time <EOL> else : <EOL> from time import time <EOL> from time import sleep <EOL> class EVENT_LOOP ( unittest . TestCase ) : <EOL> def t_scheduled ( self , interval , iterations , sleep_time = <NUM_LIT:0> ) : <EOL> warmup_iterations = iterations <EOL> self . last_t = <NUM_LIT:0.> <EOL> self . timer_count = <NUM_LIT:0> <EOL> def f ( dt ) : <EOL> t = time ( ) <EOL> self . timer_count += <NUM_LIT:1> <EOL> tc = self . timer_count <EOL> if tc > warmup_iterations : <EOL> self . assertAlmostEqual ( dt , interval , places = <NUM_LIT:2> ) <EOL> self . assertAlmostEqual ( t - self . last_t , interval , places = <NUM_LIT:2> ) <EOL> self . last_t = t <EOL> if self . timer_count > iterations + warmup_iterations : <EOL> pyglet . app . exit ( ) <EOL> if sleep_time : <EOL> sleep ( sleep_time ) <EOL> pyglet . clock . schedule_interval ( f , interval ) <EOL> try : <EOL> pyglet . app . run ( ) <EOL> finally : <EOL> pyglet . clock . unschedule ( f ) <EOL> def test_1_5 ( self ) : <EOL> self . t_scheduled ( <NUM_LIT:1> , <NUM_LIT:5> , <NUM_LIT:0> ) <EOL> def test_1_5_d5 ( self ) : <EOL> self . t_scheduled ( <NUM_LIT:1> , <NUM_LIT:5> , <NUM_LIT:0.5> ) <EOL> def test_d1_50 ( self ) : <EOL> self . t_scheduled ( <NUM_LIT> , <NUM_LIT:50> ) <EOL> def test_d1_50_d05 ( self ) : <EOL> self . t_scheduled ( <NUM_LIT> , <NUM_LIT:50> , <NUM_LIT> ) <EOL> def test_d05_50 ( self ) : <EOL> self . t_scheduled ( <NUM_LIT> , <NUM_LIT:50> ) <EOL> def test_d05_50_d03 ( self ) : <EOL> self . t_scheduled ( <NUM_LIT> , <NUM_LIT:50> , <NUM_LIT> ) <EOL> def test_d02_50 ( self ) : <EOL> self . t_scheduled ( <NUM_LIT> , <NUM_LIT:50> ) <EOL> def test_d01_50 ( self ) : <EOL> self . t_scheduled ( <NUM_LIT> , <NUM_LIT:50> ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> if pyglet . version != '<STR_LIT>' : <EOL> print '<STR_LIT>' <EOL> else : <EOL> unittest . main ( ) </s>
