Files
RustPython/tests/snippets/types.py
Adam Kelly ca7b792497 Get both forms of type to work properly.
Includes basic ability to traverse method resolution order (mro), but
not to derive mro or read parents from class definitions.

New and init called when creating types and instances.
__call__ works on types and instances.
Descriptors have have priority over instance variables.
2018-08-18 11:54:00 +01:00

17 lines
368 B
Python

assert type(type) is type
assert type(object) is type
assert type(object()) is object
new_type = type('New', (object,), {})
assert type(new_type) is type
assert type(new_type()) is new_type
metaclass = type('MCl', (type,), {})
cls = metaclass('Cls', (object,), {})
inst = cls()
assert type(inst) is cls
assert type(cls) is metaclass
assert type(metaclass) is type