mirror of
https://github.com/python/cpython.git
synced 2025-09-27 18:59:43 +00:00
Add a test case suggested by Guido, where a method is created with the
new module.
This commit is contained in:
parent
83ad5015cb
commit
534c60f9ab
1 changed files with 38 additions and 0 deletions
|
@ -100,3 +100,41 @@ else:
|
||||||
|
|
||||||
if f2.a.one <> f1.a.one <> F.a.one <> 11:
|
if f2.a.one <> f1.a.one <> F.a.one <> 11:
|
||||||
raise TestFailed
|
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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue