forked from runtimeverification/python-semantics
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestclasses3.py
More file actions
28 lines (24 loc) · 705 Bytes
/
Copy pathtestclasses3.py
File metadata and controls
28 lines (24 loc) · 705 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
class M2(type):
def __prepare__(name, bases, **kwargs):
assert name == "C"
assert bases == ()
assert kwargs["x"] == 5
assert "metaclass" not in kwargs
return {"a": 1}
def __new__(cls, name, bases, classdict, **kwargs):
assert cls == M2
assert name == "C"
assert bases == ()
assert kwargs["x"] == 5
assert classdict["a"] == 1
classdict["b"] = 2
return type.__new__(cls, name, bases, classdict)
def __init__(self, name, bases, classdict, **kwargs):
assert name == "C"
assert bases == ()
assert classdict["a"] == 1
assert classdict["b"] == 2
self.c = 3
assert kwargs["x"] == 5
class C(metaclass=M2, x=5): pass
assert C.c == 3