| 1 |
import unittest |
| 2 |
from ctypes import Structure, c_char, c_int |
| 3 |
|
| 4 |
|
| 5 |
class X(Structure): |
| 6 |
_fields_ = [("foo", c_int)] |
| 7 |
|
| 8 |
|
| 9 |
class TestCase(unittest.TestCase): |
| 10 |
def test_simple(self): |
| 11 |
with self.assertRaises(TypeError): |
| 12 |
del c_int(42).value |
| 13 |
|
| 14 |
def test_chararray(self): |
| 15 |
chararray = (c_char * 5)() |
| 16 |
with self.assertRaises(TypeError): |
| 17 |
del chararray.value |
| 18 |
|
| 19 |
def test_struct(self): |
| 20 |
struct = X() |
| 21 |
with self.assertRaises(TypeError): |
| 22 |
del struct.foo |
| 23 |
|
| 24 |
|
| 25 |
if __name__ == "__main__": |
| 26 |
unittest.main() |