summaryrefslogtreecommitdiffstats
path: root/Lib/ctypes/test
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-05-02 19:09:54 (GMT)
committerGuido van Rossum <guido@python.org>2007-05-02 19:09:54 (GMT)
commitef87d6ed94780fe00250a551031023aeb2898365 (patch)
tree1f8989aaaec7ec5f8b2f26498317f2022bf85531 /Lib/ctypes/test
parent572dbf8f1320c0b34b9c786e5c30ba4a4b61b292 (diff)
downloadcpython-ef87d6ed94780fe00250a551031023aeb2898365.zip
cpython-ef87d6ed94780fe00250a551031023aeb2898365.tar.gz
cpython-ef87d6ed94780fe00250a551031023aeb2898365.tar.bz2
Rip out all the u"..." literals and calls to unicode().
Diffstat (limited to 'Lib/ctypes/test')
-rw-r--r--Lib/ctypes/test/test_as_parameter.py2
-rw-r--r--Lib/ctypes/test/test_buffers.py14
-rw-r--r--Lib/ctypes/test/test_functions.py4
-rw-r--r--Lib/ctypes/test/test_parameters.py10
-rw-r--r--Lib/ctypes/test/test_prototypes.py16
-rw-r--r--Lib/ctypes/test/test_slicing.py6
-rw-r--r--Lib/ctypes/test/test_strings.py46
-rw-r--r--Lib/ctypes/test/test_structures.py10
-rw-r--r--Lib/ctypes/test/test_unicode.py38
9 files changed, 73 insertions, 73 deletions
diff --git a/Lib/ctypes/test/test_as_parameter.py b/Lib/ctypes/test/test_as_parameter.py
index 4a33332..e21782b 100644
--- a/Lib/ctypes/test/test_as_parameter.py
+++ b/Lib/ctypes/test/test_as_parameter.py
@@ -24,7 +24,7 @@ class BasicWrapTestCase(unittest.TestCase):
return
f = dll._testfunc_i_bhilfd
f.argtypes = [c_byte, c_wchar, c_int, c_long, c_float, c_double]
- result = f(self.wrap(1), self.wrap(u"x"), self.wrap(3), self.wrap(4), self.wrap(5.0), self.wrap(6.0))
+ result = f(self.wrap(1), self.wrap("x"), self.wrap(3), self.wrap(4), self.wrap(5.0), self.wrap(6.0))
self.failUnlessEqual(result, 139)
self.failUnless(type(result), int)
diff --git a/Lib/ctypes/test/test_buffers.py b/Lib/ctypes/test/test_buffers.py
index 07527a6..72cd0dd 100644
--- a/Lib/ctypes/test/test_buffers.py
+++ b/Lib/ctypes/test/test_buffers.py
@@ -17,7 +17,7 @@ class StringBufferTestCase(unittest.TestCase):
self.failUnlessEqual(b[:], "abc\0")
def test_string_conversion(self):
- b = create_string_buffer(u"abc")
+ 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)
@@ -33,21 +33,21 @@ class StringBufferTestCase(unittest.TestCase):
b = create_unicode_buffer(32)
self.failUnlessEqual(len(b), 32)
self.failUnlessEqual(sizeof(b), 32 * sizeof(c_wchar))
- self.failUnless(type(b[0]) is unicode)
+ self.failUnless(type(b[0]) is str)
- b = create_unicode_buffer(u"abc")
+ b = create_unicode_buffer("abc")
self.failUnlessEqual(len(b), 4) # trailing nul char
self.failUnlessEqual(sizeof(b), 4 * sizeof(c_wchar))
- self.failUnless(type(b[0]) is unicode)
- self.failUnlessEqual(b[0], u"a")
+ self.failUnless(type(b[0]) is str)
+ self.failUnlessEqual(b[0], "a")
self.failUnlessEqual(b[:], "abc\0")
def test_unicode_conversion(self):
b = create_unicode_buffer("abc")
self.failUnlessEqual(len(b), 4) # trailing nul char
self.failUnlessEqual(sizeof(b), 4 * sizeof(c_wchar))
- self.failUnless(type(b[0]) is unicode)
- self.failUnlessEqual(b[0], u"a")
+ self.failUnless(type(b[0]) is str)
+ self.failUnlessEqual(b[0], "a")
self.failUnlessEqual(b[:], "abc\0")
if __name__ == "__main__":
diff --git a/Lib/ctypes/test/test_functions.py b/Lib/ctypes/test/test_functions.py
index 40892b9..bbcbbc1 100644
--- a/Lib/ctypes/test/test_functions.py
+++ b/Lib/ctypes/test/test_functions.py
@@ -70,7 +70,7 @@ class FunctionTestCase(unittest.TestCase):
return
f = dll._testfunc_i_bhilfd
f.argtypes = [c_byte, c_wchar, c_int, c_long, c_float, c_double]
- result = f(1, u"x", 3, 4, 5.0, 6.0)
+ result = f(1, "x", 3, 4, 5.0, 6.0)
self.failUnlessEqual(result, 139)
self.failUnlessEqual(type(result), int)
@@ -83,7 +83,7 @@ class FunctionTestCase(unittest.TestCase):
f.argtypes = [c_byte, c_short, c_int, c_long, c_float, c_double]
f.restype = c_wchar
result = f(0, 0, 0, 0, 0, 0)
- self.failUnlessEqual(result, u'\x00')
+ self.failUnlessEqual(result, '\x00')
def test_voidresult(self):
f = dll._testfunc_v
diff --git a/Lib/ctypes/test/test_parameters.py b/Lib/ctypes/test/test_parameters.py
index 1b7f0dc..84d8eaf 100644
--- a/Lib/ctypes/test/test_parameters.py
+++ b/Lib/ctypes/test/test_parameters.py
@@ -58,8 +58,8 @@ class SimpleTypesTestCase(unittest.TestCase):
self.failUnless(c_char_p.from_param(s)._obj is s)
# new in 0.9.1: convert (encode) unicode to ascii
- self.failUnlessEqual(c_char_p.from_param(u"123")._obj, "123")
- self.assertRaises(UnicodeEncodeError, c_char_p.from_param, u"123\377")
+ self.failUnlessEqual(c_char_p.from_param("123")._obj, "123")
+ self.assertRaises(UnicodeEncodeError, c_char_p.from_param, "123\377")
self.assertRaises(TypeError, c_char_p.from_param, 42)
@@ -75,16 +75,16 @@ class SimpleTypesTestCase(unittest.TestCase):
except ImportError:
## print "(No c_wchar_p)"
return
- s = u"123"
+ s = "123"
if sys.platform == "win32":
self.failUnless(c_wchar_p.from_param(s)._obj is s)
self.assertRaises(TypeError, c_wchar_p.from_param, 42)
# new in 0.9.1: convert (decode) ascii to unicode
- self.failUnlessEqual(c_wchar_p.from_param("123")._obj, u"123")
+ self.failUnlessEqual(c_wchar_p.from_param("123")._obj, "123")
self.assertRaises(UnicodeDecodeError, c_wchar_p.from_param, "123\377")
- pa = c_wchar_p.from_param(c_wchar_p(u"123"))
+ pa = c_wchar_p.from_param(c_wchar_p("123"))
self.failUnlessEqual(type(pa), c_wchar_p)
def test_int_pointers(self):
diff --git a/Lib/ctypes/test/test_prototypes.py b/Lib/ctypes/test/test_prototypes.py
index 56ddf4a..b14d2d8 100644
--- a/Lib/ctypes/test/test_prototypes.py
+++ b/Lib/ctypes/test/test_prototypes.py
@@ -123,7 +123,7 @@ class CharPointersTestCase(unittest.TestCase):
pass
else:
self.failUnlessEqual(None, func(c_wchar_p(None)))
- self.failUnlessEqual(u"123", func(c_wchar_p(u"123")))
+ self.failUnlessEqual("123", func(c_wchar_p("123")))
def test_instance(self):
func = testdll._testfunc_p_p
@@ -157,24 +157,24 @@ else:
func.argtypes = POINTER(c_wchar),
self.failUnlessEqual(None, func(None))
- self.failUnlessEqual(u"123", func(u"123"))
+ self.failUnlessEqual("123", func("123"))
self.failUnlessEqual(None, func(c_wchar_p(None)))
- self.failUnlessEqual(u"123", func(c_wchar_p(u"123")))
+ self.failUnlessEqual("123", func(c_wchar_p("123")))
- self.failUnlessEqual(u"123", func(c_wbuffer(u"123")))
+ self.failUnlessEqual("123", func(c_wbuffer("123")))
ca = c_wchar("a")
- self.failUnlessEqual(u"a", func(pointer(ca))[0])
- self.failUnlessEqual(u"a", func(byref(ca))[0])
+ self.failUnlessEqual("a", func(pointer(ca))[0])
+ self.failUnlessEqual("a", func(byref(ca))[0])
def test_c_wchar_p_arg(self):
func = testdll._testfunc_p_p
func.restype = c_wchar_p
func.argtypes = c_wchar_p,
- c_wchar_p.from_param(u"123")
+ c_wchar_p.from_param("123")
self.failUnlessEqual(None, func(None))
- self.failUnlessEqual("123", func(u"123"))
+ self.failUnlessEqual("123", func("123"))
self.failUnlessEqual(None, func(c_wchar_p(None)))
self.failUnlessEqual("123", func(c_wchar_p("123")))
diff --git a/Lib/ctypes/test/test_slicing.py b/Lib/ctypes/test/test_slicing.py
index 511c3d3..54fbfaa 100644
--- a/Lib/ctypes/test/test_slicing.py
+++ b/Lib/ctypes/test/test_slicing.py
@@ -45,7 +45,7 @@ class SlicesTestCase(unittest.TestCase):
import operator
self.assertRaises(TypeError, operator.setslice,
- res, 0, 5, u"abcde")
+ res, 0, 5, "abcde")
dll.my_free(res)
dll.my_strdup.restype = POINTER(c_byte)
@@ -88,7 +88,7 @@ class SlicesTestCase(unittest.TestCase):
pass
else:
def test_wchar_ptr(self):
- s = u"abcdefghijklmnopqrstuvwxyz\0"
+ s = "abcdefghijklmnopqrstuvwxyz\0"
dll = CDLL(_ctypes_test.__file__)
dll.my_wcsdup.restype = POINTER(c_wchar)
@@ -99,7 +99,7 @@ class SlicesTestCase(unittest.TestCase):
import operator
self.assertRaises(TypeError, operator.setslice,
- res, 0, 5, u"abcde")
+ res, 0, 5, "abcde")
dll.my_free(res)
if sizeof(c_wchar) == sizeof(c_short):
diff --git a/Lib/ctypes/test/test_strings.py b/Lib/ctypes/test/test_strings.py
index aca7282..3100b79 100644
--- a/Lib/ctypes/test/test_strings.py
+++ b/Lib/ctypes/test/test_strings.py
@@ -62,17 +62,17 @@ else:
def test(self):
BUF = c_wchar * 4
- buf = BUF(u"a", u"b", u"c")
- self.failUnlessEqual(buf.value, u"abc")
+ buf = BUF("a", "b", "c")
+ self.failUnlessEqual(buf.value, "abc")
- buf.value = u"ABCD"
- self.failUnlessEqual(buf.value, u"ABCD")
+ buf.value = "ABCD"
+ self.failUnlessEqual(buf.value, "ABCD")
- buf.value = u"x"
- self.failUnlessEqual(buf.value, u"x")
+ buf.value = "x"
+ self.failUnlessEqual(buf.value, "x")
- buf[1] = u"Z"
- self.failUnlessEqual(buf.value, u"xZCD")
+ buf[1] = "Z"
+ self.failUnlessEqual(buf.value, "xZCD")
class StringTestCase(unittest.TestCase):
def XX_test_basic_strings(self):
@@ -99,7 +99,7 @@ class StringTestCase(unittest.TestCase):
self.failUnlessEqual(cs.value, "XY")
self.failUnlessEqual(cs.raw, "XY\000\000\000\000\000")
- self.assertRaises(TypeError, c_string, u"123")
+ self.assertRaises(TypeError, c_string, "123")
def XX_test_sized_strings(self):
@@ -142,13 +142,13 @@ except NameError:
else:
class WStringTestCase(unittest.TestCase):
def test_wchar(self):
- c_wchar(u"x")
- repr(byref(c_wchar(u"x")))
+ c_wchar("x")
+ repr(byref(c_wchar("x")))
c_wchar("x")
def X_test_basic_wstrings(self):
- cs = c_wstring(u"abcdef")
+ cs = c_wstring("abcdef")
# XXX This behaviour is about to change:
# len returns the size of the internal buffer in bytes.
@@ -156,30 +156,30 @@ else:
self.failUnless(sizeof(cs) == 14)
# The value property is the string up to the first terminating NUL.
- self.failUnless(cs.value == u"abcdef")
- self.failUnless(c_wstring(u"abc\000def").value == u"abc")
+ self.failUnless(cs.value == "abcdef")
+ self.failUnless(c_wstring("abc\000def").value == "abc")
- self.failUnless(c_wstring(u"abc\000def").value == u"abc")
+ self.failUnless(c_wstring("abc\000def").value == "abc")
# The raw property is the total buffer contents:
- self.failUnless(cs.raw == u"abcdef\000")
- self.failUnless(c_wstring(u"abc\000def").raw == u"abc\000def\000")
+ self.failUnless(cs.raw == "abcdef\000")
+ self.failUnless(c_wstring("abc\000def").raw == "abc\000def\000")
# We can change the value:
- cs.value = u"ab"
- self.failUnless(cs.value == u"ab")
- self.failUnless(cs.raw == u"ab\000\000\000\000\000")
+ cs.value = "ab"
+ self.failUnless(cs.value == "ab")
+ self.failUnless(cs.raw == "ab\000\000\000\000\000")
self.assertRaises(TypeError, c_wstring, "123")
self.assertRaises(ValueError, c_wstring, 0)
def X_test_toolong(self):
- cs = c_wstring(u"abcdef")
+ cs = c_wstring("abcdef")
# Much too long string:
- self.assertRaises(ValueError, setattr, cs, "value", u"123456789012345")
+ self.assertRaises(ValueError, setattr, cs, "value", "123456789012345")
# One char too long values:
- self.assertRaises(ValueError, setattr, cs, "value", u"1234567")
+ self.assertRaises(ValueError, setattr, cs, "value", "1234567")
def run_test(rep, msg, func, arg):
diff --git a/Lib/ctypes/test/test_structures.py b/Lib/ctypes/test/test_structures.py
index 389f937..ab98a66 100644
--- a/Lib/ctypes/test/test_structures.py
+++ b/Lib/ctypes/test/test_structures.py
@@ -269,15 +269,15 @@ class StructureTestCase(unittest.TestCase):
_fields_ = [("name", c_wchar * 12),
("age", c_int)]
- p = PersonW(u"Someone")
+ p = PersonW("Someone")
self.failUnlessEqual(p.name, "Someone")
- self.failUnlessEqual(PersonW(u"1234567890").name, u"1234567890")
- self.failUnlessEqual(PersonW(u"12345678901").name, u"12345678901")
+ self.failUnlessEqual(PersonW("1234567890").name, "1234567890")
+ self.failUnlessEqual(PersonW("12345678901").name, "12345678901")
# exact fit
- self.failUnlessEqual(PersonW(u"123456789012").name, u"123456789012")
+ self.failUnlessEqual(PersonW("123456789012").name, "123456789012")
#too long
- self.assertRaises(ValueError, PersonW, u"1234567890123")
+ self.assertRaises(ValueError, PersonW, "1234567890123")
def test_init_errors(self):
class Phone(Structure):
diff --git a/Lib/ctypes/test/test_unicode.py b/Lib/ctypes/test/test_unicode.py
index 78c5cf8..f8e6f09 100644
--- a/Lib/ctypes/test/test_unicode.py
+++ b/Lib/ctypes/test/test_unicode.py
@@ -23,31 +23,31 @@ else:
def test_ascii_strict(self):
ctypes.set_conversion_mode("ascii", "strict")
# no conversions take place with unicode arguments
- self.failUnlessEqual(wcslen(u"abc"), 3)
- self.failUnlessEqual(wcslen(u"ab\u2070"), 3)
+ self.failUnlessEqual(wcslen("abc"), 3)
+ self.failUnlessEqual(wcslen("ab\u2070"), 3)
# string args are converted
self.failUnlessEqual(wcslen("abc"), 3)
self.failUnlessRaises(ctypes.ArgumentError, wcslen, "abä")
def test_ascii_replace(self):
ctypes.set_conversion_mode("ascii", "replace")
- self.failUnlessEqual(wcslen(u"abc"), 3)
- self.failUnlessEqual(wcslen(u"ab\u2070"), 3)
+ self.failUnlessEqual(wcslen("abc"), 3)
+ self.failUnlessEqual(wcslen("ab\u2070"), 3)
self.failUnlessEqual(wcslen("abc"), 3)
self.failUnlessEqual(wcslen("abä"), 3)
def test_ascii_ignore(self):
ctypes.set_conversion_mode("ascii", "ignore")
- self.failUnlessEqual(wcslen(u"abc"), 3)
- self.failUnlessEqual(wcslen(u"ab\u2070"), 3)
+ self.failUnlessEqual(wcslen("abc"), 3)
+ self.failUnlessEqual(wcslen("ab\u2070"), 3)
# ignore error mode skips non-ascii characters
self.failUnlessEqual(wcslen("abc"), 3)
self.failUnlessEqual(wcslen("äöüß"), 0)
def test_latin1_strict(self):
ctypes.set_conversion_mode("latin-1", "strict")
- self.failUnlessEqual(wcslen(u"abc"), 3)
- self.failUnlessEqual(wcslen(u"ab\u2070"), 3)
+ self.failUnlessEqual(wcslen("abc"), 3)
+ self.failUnlessEqual(wcslen("ab\u2070"), 3)
self.failUnlessEqual(wcslen("abc"), 3)
self.failUnlessEqual(wcslen("äöüß"), 4)
@@ -58,12 +58,12 @@ else:
ctypes.set_conversion_mode("ascii", "replace")
buf = ctypes.create_unicode_buffer("abäöü")
- self.failUnlessEqual(buf[:], u"ab\uFFFD\uFFFD\uFFFD\0")
+ self.failUnlessEqual(buf[:], "ab\uFFFD\uFFFD\uFFFD\0")
ctypes.set_conversion_mode("ascii", "ignore")
buf = ctypes.create_unicode_buffer("abäöü")
# is that correct? not sure. But with 'ignore', you get what you pay for..
- self.failUnlessEqual(buf[:], u"ab\0\0\0\0")
+ self.failUnlessEqual(buf[:], "ab\0\0\0\0")
import _ctypes_test
func = ctypes.CDLL(_ctypes_test.__file__)._testfunc_p_p
@@ -82,32 +82,32 @@ else:
def test_ascii_replace(self):
ctypes.set_conversion_mode("ascii", "strict")
self.failUnlessEqual(func("abc"), "abc")
- self.failUnlessEqual(func(u"abc"), "abc")
- self.assertRaises(ctypes.ArgumentError, func, u"abä")
+ self.failUnlessEqual(func("abc"), "abc")
+ self.assertRaises(ctypes.ArgumentError, func, "abä")
def test_ascii_ignore(self):
ctypes.set_conversion_mode("ascii", "ignore")
self.failUnlessEqual(func("abc"), "abc")
- self.failUnlessEqual(func(u"abc"), "abc")
- self.failUnlessEqual(func(u"äöüß"), "")
+ self.failUnlessEqual(func("abc"), "abc")
+ self.failUnlessEqual(func("äöüß"), "")
def test_ascii_replace(self):
ctypes.set_conversion_mode("ascii", "replace")
self.failUnlessEqual(func("abc"), "abc")
- self.failUnlessEqual(func(u"abc"), "abc")
- self.failUnlessEqual(func(u"äöüß"), "????")
+ self.failUnlessEqual(func("abc"), "abc")
+ self.failUnlessEqual(func("äöüß"), "????")
def test_buffers(self):
ctypes.set_conversion_mode("ascii", "strict")
- buf = ctypes.create_string_buffer(u"abc")
+ buf = ctypes.create_string_buffer("abc")
self.failUnlessEqual(len(buf), 3+1)
ctypes.set_conversion_mode("ascii", "replace")
- buf = ctypes.create_string_buffer(u"abäöü")
+ buf = ctypes.create_string_buffer("abäöü")
self.failUnlessEqual(buf[:], "ab???\0")
ctypes.set_conversion_mode("ascii", "ignore")
- buf = ctypes.create_string_buffer(u"abäöü")
+ buf = ctypes.create_string_buffer("abäöü")
# is that correct? not sure. But with 'ignore', you get what you pay for..
self.failUnlessEqual(buf[:], "ab\0\0\0\0")