From 534c60f9ab1e2bba453690e659d2a86f3ad6439d Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Mon, 15 Jan 2001 21:00:02 +0000 Subject: Add a test case suggested by Guido, where a method is created with the new module. --- Lib/test/test_funcattrs.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/Lib/test/test_funcattrs.py b/Lib/test/test_funcattrs.py index f8b471e..9d3ec18 100644 --- a/Lib/test/test_funcattrs.py +++ b/Lib/test/test_funcattrs.py @@ -100,3 +100,41 @@ else: if f2.a.one <> f1.a.one <> F.a.one <> 11: raise TestFailed + +# im_func may not be a Python method! +import new +F.id = new.instancemethod(id, None, F) + +eff = F() +if eff.id() <> id(eff): + raise TestFailed + +try: + F.id.foo +except AttributeError: pass +else: raise TestFailed + +try: + F.id.foo = 12 +except TypeError: pass +else: raise TestFailed + +try: + F.id.foo +except AttributeError: pass +else: raise TestFailed + +try: + eff.id.foo +except AttributeError: pass +else: raise TestFailed + +try: + eff.id.foo = 12 +except TypeError: pass +else: raise TestFailed + +try: + eff.id.foo +except AttributeError: pass +else: raise TestFailed -- cgit v0.12