|
2 | 2 | from ctypes import * |
3 | 3 | from ctypes.test import need_symbol |
4 | 4 | from struct import calcsize |
5 | | -import _testcapi |
| 5 | +try: |
| 6 | + import _testcapi |
| 7 | +except ImportError: |
| 8 | + _testcapi = None |
6 | 9 |
|
7 | 10 | class SubclassesTest(unittest.TestCase): |
8 | 11 | def test_subclass(self): |
@@ -201,13 +204,14 @@ class X(Structure): |
201 | 204 | "_pack_": -1} |
202 | 205 | self.assertRaises(ValueError, type(Structure), "X", (Structure,), d) |
203 | 206 |
|
204 | | - # Issue 15989 |
205 | | - d = {"_fields_": [("a", c_byte)], |
206 | | - "_pack_": _testcapi.INT_MAX + 1} |
207 | | - self.assertRaises(ValueError, type(Structure), "X", (Structure,), d) |
208 | | - d = {"_fields_": [("a", c_byte)], |
209 | | - "_pack_": _testcapi.UINT_MAX + 2} |
210 | | - self.assertRaises(ValueError, type(Structure), "X", (Structure,), d) |
| 207 | + if _testcapi: |
| 208 | + # Issue 15989 |
| 209 | + d = {"_fields_": [("a", c_byte)], |
| 210 | + "_pack_": _testcapi.INT_MAX + 1} |
| 211 | + self.assertRaises(ValueError, type(Structure), "X", (Structure,), d) |
| 212 | + d = {"_fields_": [("a", c_byte)], |
| 213 | + "_pack_": _testcapi.UINT_MAX + 2} |
| 214 | + self.assertRaises(ValueError, type(Structure), "X", (Structure,), d) |
211 | 215 |
|
212 | 216 | def test_initializers(self): |
213 | 217 | class Person(Structure): |
|
0 commit comments