1.1 --- a/tests/get_using.py Mon Jan 23 23:28:19 2017 +0100
1.2 +++ b/tests/get_using.py Mon Jan 23 23:46:20 2017 +0100
1.3 @@ -3,17 +3,33 @@
1.4 self.x = 123
1.5
1.6 def f(self):
1.7 - print self
1.8 return self.x
1.9
1.10 +class D:
1.11 + pass
1.12 +
1.13 c = C()
1.14 f = C.f
1.15 fn = get_using(C.f, c)
1.16 print fn # __main__.C.f
1.17 print fn() # 123
1.18 +
1.19 fn = get_using(C.f, C)
1.20 print fn # __main__.C.f
1.21 try:
1.22 print fn() # fails
1.23 except UnboundMethodInvocation:
1.24 print "fn(): method is unbound"
1.25 +
1.26 +d = D()
1.27 +try:
1.28 + fn = get_using(C.f, d)
1.29 +except TypeError:
1.30 + print "get_using(C.f, d): d is not compatible with C"
1.31 +
1.32 +fn = get_using(c, C.f)
1.33 +print fn # <__main__.C instance>
1.34 +try:
1.35 + print fn() # fails
1.36 +except TypeError:
1.37 + print "fn(): object is not callable"