summaryrefslogtreecommitdiffstats
path: root/Lib/ctypes
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2011-07-14 04:11:14 (GMT)
committerBenjamin Peterson <benjamin@python.org>2011-07-14 04:11:14 (GMT)
commitd77e2eaa4026af658dab927a39385f1ef361ec5f (patch)
tree2aec5d08859d2d49acaa7910417ac35177225cba /Lib/ctypes
parentbf9c021ddd12eb9bd7c6ce450a1c401e348c09fc (diff)
parent6e18e04273877e04da0c9516d9c016e650bc72ec (diff)
downloadcpython-d77e2eaa4026af658dab927a39385f1ef361ec5f.zip
cpython-d77e2eaa4026af658dab927a39385f1ef361ec5f.tar.gz
cpython-d77e2eaa4026af658dab927a39385f1ef361ec5f.tar.bz2
merge 3.2
Diffstat (limited to 'Lib/ctypes')
-rw-r--r--Lib/ctypes/test/test_byteswap.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/Lib/ctypes/test/test_byteswap.py b/Lib/ctypes/test/test_byteswap.py
index 3366ba6..0d2974f 100644
--- a/Lib/ctypes/test/test_byteswap.py
+++ b/Lib/ctypes/test/test_byteswap.py
@@ -1,4 +1,4 @@
-import sys, unittest, struct, math
+import sys, unittest, struct, math, ctypes
from binascii import hexlify
from ctypes import *
@@ -188,16 +188,6 @@ class Test(unittest.TestCase):
# nested structures with different byteorders
# create nested structures with given byteorders and set memory to data
- def set_structures(endianness, nested_endianness, data):
- class NestedStructure(nested_endianness):
- _fields_ = [("x", c_uint32),
- ("y", c_uint32)]
-
- class TestStructure(endianness):
- _fields_ = [("point", NestedStructure)]
-
- self.assertEqual(len(data), sizeof(TestStructure))
- return cast(data, POINTER(TestStructure))[0]
for nested, data in (
(BigEndianStructure, b'\0\0\0\1\0\0\0\2'),
@@ -208,7 +198,17 @@ class Test(unittest.TestCase):
LittleEndianStructure,
Structure,
):
- s = set_structures(parent, nested, data)
+ class NestedStructure(nested):
+ _fields_ = [("x", c_uint32),
+ ("y", c_uint32)]
+
+ class TestStructure(parent):
+ _fields_ = [("point", NestedStructure)]
+
+ self.assertEqual(len(data), sizeof(TestStructure))
+ ptr = POINTER(TestStructure)
+ s = cast(data, ptr)[0]
+ del ctypes._pointer_type_cache[TestStructure]
self.assertEqual(s.point.x, 1)
self.assertEqual(s.point.y, 2)