Skip to content

Commit 19263d2

Browse files
committed
type test for __new__
1 parent 97f9390 commit 19263d2

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

extra_tests/snippets/class.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,3 +265,20 @@ class B: pass
265265

266266
class C(*(A, B), **{"metaclass": type}):
267267
pass
268+
269+
class A(type):
270+
def __new__(mcls):
271+
assert type(mcls.__new__).__name__ == 'function'
272+
assert type(mcls.mro).__name__ == 'method_descriptor'
273+
assert type(super().__new__).__name__ in ['builtin_function_or_method', 'method']
274+
assert type(super().mro).__name__ == 'method_descriptor'
275+
276+
class B(type):
277+
def x(self):
278+
assert type(self.__new__).__name__ in ['builtin_function_or_method', 'method']
279+
assert type(self.mro).__name__ in ['builtin_function_or_method', 'method']
280+
assert type(super().__new__).__name__ in ['builtin_function_or_method', 'method']
281+
assert type(super().mro).__name__ in ['builtin_function_or_method', 'method']
282+
283+
A()
284+
B('x', (int,), {}).x()

0 commit comments

Comments
 (0)