summaryrefslogtreecommitdiff
path: root/Lib/test/test_metaclass.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-08-02 16:48:17 +0000
committerGuido van Rossum <guido@python.org>2007-08-02 16:48:17 +0000
commit4737482fada222f2353b9abc9bcf14bfac49fb79 (patch)
treeb015be13b0bf0c7b556a745d58e23dddf657b767 /Lib/test/test_metaclass.py
parenta9efc8e2684a04ae37c1528fd8f079247b6a0536 (diff)
downloadcpython-git-4737482fada222f2353b9abc9bcf14bfac49fb79.tar.gz
Add a default __prepare__() method to 'type', so it can be called
using super(). (See recent conversation on python-3000 with Talin and Phillip Eby about PEP 3115 chaining rules.)
Diffstat (limited to 'Lib/test/test_metaclass.py')
-rw-r--r--Lib/test/test_metaclass.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/Lib/test/test_metaclass.py b/Lib/test/test_metaclass.py
index 9126cf6524..abb3330328 100644
--- a/Lib/test/test_metaclass.py
+++ b/Lib/test/test_metaclass.py
@@ -207,6 +207,29 @@ And again, with a __prepare__ attribute.
kw: [('other', 'booh')]
>>>
+The default metaclass must define a __prepare__() method.
+
+ >>> type.__prepare__()
+ {}
+ >>>
+
+Make sure it works with subclassing.
+
+ >>> class M(type):
+ ... @classmethod
+ ... def __prepare__(cls, *args, **kwds):
+ ... d = super().__prepare__(*args, **kwds)
+ ... d["hello"] = 42
+ ... return d
+ ...
+ >>> class C(metaclass=M):
+ ... print(hello)
+ ...
+ 42
+ >>> print(C.hello)
+ 42
+ >>>
+
"""
__test__ = {'doctests' : doctests}