From 90044275898f213456f522dbeb1affc9b2433308 Mon Sep 17 00:00:00 2001
From: Thomas Heller <theller@ctypes.org>
Date: Wed, 11 Jul 2007 12:25:26 +0000
Subject: Fix some simple ctypes tests.

---
 Lib/ctypes/test/test_buffers.py  |  6 +++---
 Lib/ctypes/test/test_byteswap.py |  2 +-
 Lib/ctypes/test/test_numbers.py  | 17 +++++++++--------
 3 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/Lib/ctypes/test/test_buffers.py b/Lib/ctypes/test/test_buffers.py
index 72cd0dd..7ccb2fd 100644
--- a/Lib/ctypes/test/test_buffers.py
+++ b/Lib/ctypes/test/test_buffers.py
@@ -7,12 +7,12 @@ class StringBufferTestCase(unittest.TestCase):
         b = create_string_buffer(32)
         self.failUnlessEqual(len(b), 32)
         self.failUnlessEqual(sizeof(b), 32 * sizeof(c_char))
-        self.failUnless(type(b[0]) is str)
+        self.failUnless(type(b[0]) is str8)
 
         b = create_string_buffer("abc")
         self.failUnlessEqual(len(b), 4) # trailing nul char
         self.failUnlessEqual(sizeof(b), 4 * sizeof(c_char))
-        self.failUnless(type(b[0]) is str)
+        self.failUnless(type(b[0]) is str8)
         self.failUnlessEqual(b[0], "a")
         self.failUnlessEqual(b[:], "abc\0")
 
@@ -20,7 +20,7 @@ class StringBufferTestCase(unittest.TestCase):
         b = create_string_buffer("abc")
         self.failUnlessEqual(len(b), 4) # trailing nul char
         self.failUnlessEqual(sizeof(b), 4 * sizeof(c_char))
-        self.failUnless(type(b[0]) is str)
+        self.failUnless(type(b[0]) is str8)
         self.failUnlessEqual(b[0], "a")
         self.failUnlessEqual(b[:], "abc\0")
 
diff --git a/Lib/ctypes/test/test_byteswap.py b/Lib/ctypes/test/test_byteswap.py
index 4833cbc..9ef4da4 100644
--- a/Lib/ctypes/test/test_byteswap.py
+++ b/Lib/ctypes/test/test_byteswap.py
@@ -4,7 +4,7 @@ from binascii import hexlify
 from ctypes import *
 
 def bin(s):
-    return hexlify(buffer(s)).upper()
+    return str(hexlify(buffer(s))).upper()
 
 # Each *simple* type that supports different byte orders has an
 # __ctype_be__ attribute that specifies the same type in BIG ENDIAN
diff --git a/Lib/ctypes/test/test_numbers.py b/Lib/ctypes/test/test_numbers.py
index 2430ac8..fda3072 100644
--- a/Lib/ctypes/test/test_numbers.py
+++ b/Lib/ctypes/test/test_numbers.py
@@ -12,10 +12,10 @@ def valid_ranges(*types):
     for t in types:
         fmt = t._type_
         size = struct.calcsize(fmt)
-        a = struct.unpack(fmt, ("\x00"*32)[:size])[0]
-        b = struct.unpack(fmt, ("\xFF"*32)[:size])[0]
-        c = struct.unpack(fmt, ("\x7F"+"\x00"*32)[:size])[0]
-        d = struct.unpack(fmt, ("\x80"+"\xFF"*32)[:size])[0]
+        a = struct.unpack(fmt, (b"\x00"*32)[:size])[0]
+        b = struct.unpack(fmt, (b"\xFF"*32)[:size])[0]
+        c = struct.unpack(fmt, (b"\x7F"+b"\x00"*32)[:size])[0]
+        d = struct.unpack(fmt, (b"\x80"+b"\xFF"*32)[:size])[0]
         result.append((min(a, b, c, d), max(a, b, c, d)))
     return result
 
@@ -174,13 +174,14 @@ class NumberTestCase(unittest.TestCase):
         from ctypes import c_char
         from array import array
 
-        a = array('c', 'x')
+        a = array('b', [0])
+        a[0] = ord('x')
         v = c_char.from_address(a.buffer_info()[0])
-        self.failUnlessEqual(v.value, a[0])
+        self.failUnlessEqual(v.value, 'x')
         self.failUnless(type(v) is c_char)
 
-        a[0] = '?'
-        self.failUnlessEqual(v.value, a[0])
+        a[0] = ord('?')
+        self.failUnlessEqual(v.value, '?')
 
     # array does not support c_bool / 't'
     # def test_bool_from_address(self):
-- 
cgit v0.12

