mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 10:44:36 +08:00
Update test_genericclass.py from Cpython v3.11.2
This commit is contained in:
1 parent
143036aa0a
commit
034f427638
1 file changed
+10
Vendored
+10
@@ -220,28 +220,38 @@ class TestClassGetitem(unittest.TestCase):
|
||||
return None
|
||||
with self.assertRaises(TypeError):
|
||||
C_too_few[int]
|
||||
|
||||
class C_too_many:
|
||||
def __class_getitem__(cls, one, two):
|
||||
return None
|
||||
with self.assertRaises(TypeError):
|
||||
C_too_many[int]
|
||||
|
||||
# TODO: RUSTPYTHON
|
||||
@unittest.expectedFailure
|
||||
def test_class_getitem_errors_2(self):
|
||||
class C:
|
||||
def __class_getitem__(cls, item):
|
||||
return None
|
||||
with self.assertRaises(TypeError):
|
||||
C()[int]
|
||||
|
||||
class E: ...
|
||||
e = E()
|
||||
e.__class_getitem__ = lambda cls, item: 'This will not work'
|
||||
with self.assertRaises(TypeError):
|
||||
e[int]
|
||||
|
||||
class C_not_callable:
|
||||
__class_getitem__ = "Surprise!"
|
||||
with self.assertRaises(TypeError):
|
||||
C_not_callable[int]
|
||||
|
||||
class C_is_none(tuple):
|
||||
__class_getitem__ = None
|
||||
with self.assertRaisesRegex(TypeError, "C_is_none"):
|
||||
C_is_none[int]
|
||||
|
||||
def test_class_getitem_metaclass(self):
|
||||
class Meta(type):
|
||||
def __class_getitem__(cls, item):
|
||||
|
||||
Reference in new issue
Block a user