# HG changeset patch # User Paul Boddie # Date 1485211580 -3600 # Node ID 267efab8ae738c16a8a30b788aa640c5958acfa4 # Parent 8f44e9dcfe6a7c49c26e49fb16f4454f7b91a392 Expanded the test of get_using. diff -r 8f44e9dcfe6a -r 267efab8ae73 tests/get_using.py --- a/tests/get_using.py Mon Jan 23 23:28:19 2017 +0100 +++ b/tests/get_using.py Mon Jan 23 23:46:20 2017 +0100 @@ -3,17 +3,33 @@ self.x = 123 def f(self): - print self return self.x +class D: + pass + c = C() f = C.f fn = get_using(C.f, c) print fn # __main__.C.f print fn() # 123 + fn = get_using(C.f, C) print fn # __main__.C.f try: print fn() # fails except UnboundMethodInvocation: print "fn(): method is unbound" + +d = D() +try: + fn = get_using(C.f, d) +except TypeError: + print "get_using(C.f, d): d is not compatible with C" + +fn = get_using(c, C.f) +print fn # <__main__.C instance> +try: + print fn() # fails +except TypeError: + print "fn(): object is not callable"