diff options
author | Guido van Rossum <guido@python.org> | 2001-08-17 11:55:58 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2001-08-17 11:55:58 (GMT) |
commit | 7e1ff69271413a61c69edb24de214895cdaa1fec (patch) | |
tree | 376b65f699cac7d7e3b1871af1fb1a5349b5996a /Lib | |
parent | 309b56670491bd6e3b9ac8ba9aa0a5eef3d67446 (diff) | |
download | cpython-7e1ff69271413a61c69edb24de214895cdaa1fec.zip cpython-7e1ff69271413a61c69edb24de214895cdaa1fec.tar.gz cpython-7e1ff69271413a61c69edb24de214895cdaa1fec.tar.bz2 |
Add early binding of methods to the 2nd metaclass example.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_descr.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index 247a4c4..a26a1e2 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -404,7 +404,11 @@ def metaclass(): __new__ = staticmethod(__new__) def __call__(self): it = _instance() - # XXX Should do more, but that doesn't work yet + # Early binding of methods + for key in self.dict: + if key.startswith("__"): + continue + setattr(it, key, self.dict[key].__get__(it, self)) return it class C: __metaclass__ = M2 @@ -414,6 +418,7 @@ def metaclass(): verify(C.bases == ()) verify('spam' in C.dict) c = C() + verify(c.spam() == 42) def pymods(): if verbose: print "Testing Python subclass of module..." |