Skip to content

Commit 2461e50

Browse files
neoneneencukou
authored andcommitted
Add test for swapped type creation
1 parent 16faac7 commit 2461e50

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Lib/test/test_ctypes/test_simplesubclasses.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ class T(_SimpleCData):
4141
with self.assertRaisesRegex(SystemError, "already initialized"):
4242
PyCSimpleType.__init__(T, 'ptr', (), {})
4343

44+
def test_swapped_type_creation(self):
45+
cls = PyCSimpleType.__new__(PyCSimpleType, '', (), {'_type_': 'i'})
46+
PyCSimpleType.__init__(cls)
47+
self.assertEqual(cls.__ctype_le__.__dict__.get('_type_'), 'i')
48+
self.assertEqual(cls.__ctype_be__.__dict__.get('_type_'), 'i')
49+
4450
def test_compare(self):
4551
self.assertEqual(MyInt(3), MyInt(3))
4652
self.assertNotEqual(MyInt(42), MyInt(43))

0 commit comments

Comments
 (0)