<s> import pymunk as p <EOL> from pymunk . vec2d import Vec2d <EOL> import unittest <EOL> class UnitTestArbiter ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> p . reset_shapeid_counter ( ) <EOL> self . s = p . Space ( ) <EOL> self . b1 , self . b2 = p . Body ( <NUM_LIT:1> , <NUM_LIT:10> ) , p . Body ( p . inf , p . inf ) <EOL> self . s . add ( self . b1 ) <EOL> self . b1 . position = - <NUM_LIT:10> , <NUM_LIT:1> <EOL> self . b2 . position = <NUM_LIT:0> , <NUM_LIT:0> <EOL> self . s1 , self . s2 = p . Circle ( self . b1 , <NUM_LIT:2> ) , p . Circle ( self . b2 , <NUM_LIT:2> ) <EOL> self . s . add ( self . s1 , self . s2 ) <EOL> self . s1 . collision_type = <NUM_LIT:1> <EOL> self . s2 . collision_type = <NUM_LIT:2> <EOL> self . s1 . elasticity = <NUM_LIT:0.5> <EOL> self . s2 . elasticity = <NUM_LIT:0.5> <EOL> self . s1 . friction = <NUM_LIT> <EOL> self . s2 . friction = <NUM_LIT> <EOL> def testImpulse ( self ) : <EOL> self . post_solve_done = False <EOL> self . b1 . apply_impulse ( ( <NUM_LIT:10> , <NUM_LIT:0> ) ) <EOL> def post_solve ( space , arb , test_self ) : <EOL> self . assertAlmostEqual ( arb . total_impulse . x , - <NUM_LIT> ) <EOL> self . assertAlmostEqual ( arb . total_impulse . y , <NUM_LIT> ) <EOL> self . assertAlmostEqual ( arb . total_impulse_with_friction . x , - <NUM_LIT> ) <EOL> self . assertAlmostEqual ( arb . total_impulse_with_friction . y , <NUM_LIT> ) <EOL> self . post_solve_done = True <EOL> return True <EOL> self . s . add_collision_handler ( <NUM_LIT:1> , <NUM_LIT:2> , None , None , post_solve , None , self ) <EOL> for x in range ( <NUM_LIT:7> ) : <EOL> self . s . step ( <NUM_LIT:0.1> ) <EOL> self . assert_ ( self . post_solve_done ) <EOL> def testTotalKE ( self ) : <EOL> self . b1 . apply_impulse ( ( <NUM_LIT:10> , <NUM_LIT:0> ) ) <EOL> def post_solve ( space , arb , test_self ) : <EOL> self . assertAlmostEqual ( arb . total_ke , <NUM_LIT> ) <EOL> return True <EOL> self . s . add_collision_handler ( <NUM_LIT:1> , <NUM_LIT:2> , None , None , post_solve , None , self ) <EOL> for x in range ( <NUM_LIT:7> ) : <EOL> self . s . step ( <NUM_LIT:0.1> ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> print ( "<STR_LIT>" + p . version ) <EOL> unittest . main ( ) </s>
