Skip to content

Commit 5bb9dfb

Browse files
gh-143005: fix ctypes array __class__ reassignment tests
1 parent 56903c5 commit 5bb9dfb

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

Lib/test/test_ctypes/test_arrays.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,21 +111,17 @@ def test_ctypes_array_class_assignment_incompatible(self):
111111
with self.assertRaises(TypeError):
112112
x.__class__ = B
113113

114-
def test_ctypes_array_class_assignment_abstract_target(self):
115-
class AbstractArray(Array):
116-
pass
114+
def test_ctypes_array_class_assignment_incompatible_target(self):
117115
A = c_int * 3
116+
class OtherArray(Array):
117+
_type_ = c_int
118+
_length_ = 4 # incompatible length
119+
118120
a = A()
119121

120122
with self.assertRaises(TypeError):
121-
a.__class__ = AbstractArray
123+
a.__class__ = OtherArray
122124

123-
def test_ctypes_array_class_assignment_non_array_instance(self):
124-
p = POINTER(c_int)()
125-
A = c_int * 3
126-
127-
with self.assertRaises(TypeError):
128-
p.__class__ = A
129125

130126
def test_ctypes_array_class_assignment_zero_length(self):
131127
A = c_long * 0

0 commit comments

Comments
 (0)