@pytest.mark.skipif(u'not six.PY2')
def test_sharedmethod_imfunc():
 def foo(self):
  pass
 actual_foo = foo
 class Bar(object, ):
  foo = sharedmethod(actual_foo)
 assert (Bar.foo.im_func is actual_foo)
 assert (Bar().foo.im_func is actual_foo)
 def foo(cls):
  pass
 actual_foo_2 = foo
 class MetaBar(type, ):
  foo = actual_foo_2
 class Bar(object, ):
  __metaclass__ = MetaBar
  foo = sharedmethod(actual_foo)
 assert (Bar.foo.im_func is actual_foo_2)
 assert (Bar().foo.im_func is actual_foo)
 class MetaBar(type, ):
  foo = None
 class Bar(object, ):
  __metaclass__ = MetaBar
  foo = sharedmethod(actual_foo)
 assert (Bar.foo.im_func is actual_foo)
 assert (Bar().foo.im_func is actual_foo)

@ pytest . mark . skipif ( u'not six.PY2' ) def test_sharedmethod_imfunc ( ) : def foo ( self ) : pass actual_foo = foo class Bar ( object , ) : foo = sharedmethod ( actual_foo ) assert ( Bar . foo . im_func is actual_foo ) assert ( Bar ( ) . foo . im_func is actual_foo ) def foo ( cls ) : pass actual_foo_2 = foo class MetaBar ( type , ) : foo = actual_foo_2 class Bar ( object , ) : __metaclass__ = MetaBar foo = sharedmethod ( actual_foo ) assert ( Bar . foo . im_func is actual_foo_2 ) assert ( Bar ( ) . foo . im_func is actual_foo ) class MetaBar ( type , ) : foo = None class Bar ( object , ) : __metaclass__ = MetaBar foo = sharedmethod ( actual_foo ) assert ( Bar . foo . im_func is actual_foo ) assert ( Bar ( ) . foo . im_func is actual_foo )
test that the im_func of a sharedmethod always points to the correct underlying function .