summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-12-16 09:25:56 (GMT)
committerIvan Levkivskyi <levkivskyi@gmail.com>2017-12-16 09:25:56 (GMT)
commit45700fb757591a672e9d25b8252971c2a2caeaf2 (patch)
tree80af830fb9a999bca2665b53488e3ee00ad0f747 /Lib
parent9c19b020249c451891affd81751947321a1e6957 (diff)
downloadcpython-45700fb757591a672e9d25b8252971c2a2caeaf2.zip
cpython-45700fb757591a672e9d25b8252971c2a2caeaf2.tar.gz
cpython-45700fb757591a672e9d25b8252971c2a2caeaf2.tar.bz2
Add tests for using PEP560 with classes implemented in C. (#4883)
Based on tests from #4878
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_genericclass.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_genericclass.py b/Lib/test/test_genericclass.py
index 214527b..2057fc0 100644
--- a/Lib/test/test_genericclass.py
+++ b/Lib/test/test_genericclass.py
@@ -1,4 +1,5 @@
import unittest
+from test import support
class TestMROEntry(unittest.TestCase):
@@ -248,5 +249,22 @@ class TestClassGetitem(unittest.TestCase):
self.assertEqual(C[int], 'from metaclass')
+@support.cpython_only
+class CAPITest(unittest.TestCase):
+
+ def test_c_class(self):
+ from _testcapi import Generic, GenericAlias
+ self.assertIsInstance(Generic.__class_getitem__(Generic, int), GenericAlias)
+
+ IntGeneric = Generic[int]
+ self.assertIs(type(IntGeneric), GenericAlias)
+ self.assertEqual(IntGeneric.__mro_entries__(()), (int,))
+ class C(IntGeneric):
+ pass
+ self.assertEqual(C.__bases__, (int,))
+ self.assertEqual(C.__orig_bases__, (IntGeneric,))
+ self.assertEqual(C.__mro__, (C, int, object))
+
+
if __name__ == "__main__":
unittest.main()