summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-rw-r--r--Lib/ctypes/test/test_bitfields.py2
-rw-r--r--Lib/ctypes/test/test_structures.py16
2 files changed, 9 insertions, 9 deletions
diff --git a/Lib/ctypes/test/test_bitfields.py b/Lib/ctypes/test/test_bitfields.py
index c89ee34..77de606 100644
--- a/Lib/ctypes/test/test_bitfields.py
+++ b/Lib/ctypes/test/test_bitfields.py
@@ -207,7 +207,7 @@ class BitFieldTest(unittest.TestCase):
class X(Structure):
_fields_ = [("a", c_byte, 4),
("b", c_int, 32)]
- self.assertEqual(sizeof(X), sizeof(c_int)*2)
+ self.assertEqual(sizeof(X), alignment(c_int)+sizeof(c_int))
def test_mixed_3(self):
class X(Structure):
diff --git a/Lib/ctypes/test/test_structures.py b/Lib/ctypes/test/test_structures.py
index 61b9fe7..87613ad 100644
--- a/Lib/ctypes/test/test_structures.py
+++ b/Lib/ctypes/test/test_structures.py
@@ -83,7 +83,7 @@ class StructureTestCase(unittest.TestCase):
class Y(Structure):
_fields_ = [("x", c_char * 3),
("y", c_int)]
- self.assertEqual(alignment(Y), calcsize("i"))
+ self.assertEqual(alignment(Y), alignment(c_int))
self.assertEqual(sizeof(Y), calcsize("3si"))
class SI(Structure):
@@ -175,23 +175,23 @@ class StructureTestCase(unittest.TestCase):
self.assertEqual(sizeof(X), 10)
self.assertEqual(X.b.offset, 2)
+ import struct
+ longlong_size = struct.calcsize("q")
+ longlong_align = struct.calcsize("bq") - longlong_size
+
class X(Structure):
_fields_ = [("a", c_byte),
("b", c_longlong)]
_pack_ = 4
- self.assertEqual(sizeof(X), 12)
- self.assertEqual(X.b.offset, 4)
-
- import struct
- longlong_size = struct.calcsize("q")
- longlong_align = struct.calcsize("bq") - longlong_size
+ self.assertEqual(sizeof(X), min(4, longlong_align) + longlong_size)
+ self.assertEqual(X.b.offset, min(4, longlong_align))
class X(Structure):
_fields_ = [("a", c_byte),
("b", c_longlong)]
_pack_ = 8
- self.assertEqual(sizeof(X), longlong_align + longlong_size)
+ self.assertEqual(sizeof(X), min(8, longlong_align) + longlong_size)
self.assertEqual(X.b.offset, min(8, longlong_align))