<s> from pypy . tool . descriptor import InstanceMethod <EOL> class X ( object ) : <EOL> def f ( self , * args , ** kwds ) : <EOL> return args , kwds <EOL> def test_bound ( ) : <EOL> obj = X ( ) <EOL> obj . x = <NUM_LIT:12> <EOL> meth = InstanceMethod ( X . f . im_func , obj , X ) <EOL> assert meth ( <NUM_LIT:1> , z = <NUM_LIT:2> ) == ( ( <NUM_LIT:1> , ) , { '<STR_LIT:z>' : <NUM_LIT:2> } ) <EOL> def test_unbound ( ) : <EOL> obj = X ( ) <EOL> obj . x = <NUM_LIT:12> <EOL> meth = InstanceMethod ( X . f . im_func , None , X ) <EOL> assert meth ( obj , <NUM_LIT:1> , z = <NUM_LIT:2> ) == ( ( <NUM_LIT:1> , ) , { '<STR_LIT:z>' : <NUM_LIT:2> } ) <EOL> def test_eq_hash ( ) : <EOL> obj1 = X ( ) <EOL> obj1 . x = <NUM_LIT:12> <EOL> meth1 = InstanceMethod ( X . f . im_func , obj1 , X ) <EOL> meth1bis = InstanceMethod ( X . f . im_func , obj1 , X ) <EOL> obj2 = X ( ) <EOL> obj2 . x = <NUM_LIT:12> <EOL> meth2 = InstanceMethod ( X . f . im_func , obj2 , X ) <EOL> d = { meth1 : <NUM_LIT> , meth2 : <NUM_LIT> } <EOL> assert len ( d ) == <NUM_LIT:2> <EOL> assert d [ meth1bis ] == <NUM_LIT> </s>
