Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(39)

Unified Diff: Lib/ctypes/test/test_byteswap.py

Issue 10639: reindent.py converts newlines to platform default
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Lib/ctypes/_endian.py ('k') | Lib/distutils/core.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/ctypes/test/test_byteswap.py Tue Jul 26 09:37:46 2011 +0300
+++ b/Lib/ctypes/test/test_byteswap.py Mon Jul 25 09:47:18 2011 -0400
@@ -1,4 +1,4 @@
-import sys, unittest, struct, math, ctypes
+import sys, unittest, struct, math
from binascii import hexlify
from ctypes import *
@@ -185,32 +185,18 @@
self.assertRaises(TypeError, setattr, T, "_fields_", [("x", typ)])
def test_struct_struct(self):
- # nested structures with different byteorders
+ # Nested structures with different byte order not (yet) supported
+ if sys.byteorder == "little":
+ base = BigEndianStructure
+ else:
+ base = LittleEndianStructure
- # create nested structures with given byteorders and set memory to data
-
- for nested, data in (
- (BigEndianStructure, b'\0\0\0\1\0\0\0\2'),
- (LittleEndianStructure, b'\1\0\0\0\2\0\0\0'),
- ):
- for parent in (
- BigEndianStructure,
- LittleEndianStructure,
- Structure,
- ):
- 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)
+ class T(Structure):
+ _fields_ = [("a", c_int),
+ ("b", c_int)]
+ class S(base):
+ pass
+ self.assertRaises(TypeError, setattr, S, "_fields_", [("s", T)])
def test_struct_fields_2(self):
# standard packing in struct uses no alignment.
« no previous file with comments | « Lib/ctypes/_endian.py ('k') | Lib/distutils/core.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+