summaryrefslogtreecommitdiffstats
path: root/Lib/ctypes/test
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2006-03-09 01:15:05 (GMT)
committerTim Peters <tim.peters@gmail.com>2006-03-09 01:15:05 (GMT)
commite8d09e581816aa7fdb812801c79e8f6bc55dc134 (patch)
tree200d9e379d0348c4f31284754353c212c17c4d31 /Lib/ctypes/test
parentb31c8142d5dc1b0881f92c110c4acd619af97a45 (diff)
downloadcpython-e8d09e581816aa7fdb812801c79e8f6bc55dc134.zip
cpython-e8d09e581816aa7fdb812801c79e8f6bc55dc134.tar.gz
cpython-e8d09e581816aa7fdb812801c79e8f6bc55dc134.tar.bz2
Whitespace normalization.
Diffstat (limited to 'Lib/ctypes/test')
-rw-r--r--Lib/ctypes/test/__init__.py2
-rw-r--r--Lib/ctypes/test/test_array_in_pointer.py2
-rw-r--r--Lib/ctypes/test/test_bitfields.py6
-rw-r--r--Lib/ctypes/test/test_buffers.py4
-rw-r--r--Lib/ctypes/test/test_byteswap.py2
-rw-r--r--Lib/ctypes/test/test_callbacks.py4
-rw-r--r--Lib/ctypes/test/test_funcptr.py2
-rw-r--r--Lib/ctypes/test/test_functions.py18
-rw-r--r--Lib/ctypes/test/test_keeprefs.py2
-rw-r--r--Lib/ctypes/test/test_macholib.py14
-rw-r--r--Lib/ctypes/test/test_numbers.py14
-rw-r--r--Lib/ctypes/test/test_parameters.py2
-rw-r--r--Lib/ctypes/test/test_pointers.py8
-rw-r--r--Lib/ctypes/test/test_posix.py2
-rw-r--r--Lib/ctypes/test/test_prototypes.py4
-rw-r--r--Lib/ctypes/test/test_refcounts.py10
-rw-r--r--Lib/ctypes/test/test_returnfuncptrs.py2
-rw-r--r--Lib/ctypes/test/test_strings.py8
-rw-r--r--Lib/ctypes/test/test_structures.py9
-rw-r--r--Lib/ctypes/test/test_win32.py32
20 files changed, 73 insertions, 74 deletions
diff --git a/Lib/ctypes/test/__init__.py b/Lib/ctypes/test/__init__.py
index 0464b1c..2ae5405 100644
--- a/Lib/ctypes/test/__init__.py
+++ b/Lib/ctypes/test/__init__.py
@@ -83,7 +83,7 @@ def test_with_refcounts(runner, verbosity, testcase):
ptc = ctypes._pointer_type_cache.copy()
cfc = ctypes._c_functype_cache.copy()
wfc = ctypes._win_functype_cache.copy()
-
+
# when searching for refcount leaks, we have to manually reset any
# caches that ctypes has.
def cleanup():
diff --git a/Lib/ctypes/test/test_array_in_pointer.py b/Lib/ctypes/test/test_array_in_pointer.py
index 36e3633..3ed310c 100644
--- a/Lib/ctypes/test/test_array_in_pointer.py
+++ b/Lib/ctypes/test/test_array_in_pointer.py
@@ -8,7 +8,7 @@ def dump(obj):
# between the bytes.
h = hexlify(buffer(obj))
return re.sub(r"(..)", r"\1-", h)[:-1]
-
+
class Value(Structure):
_fields_ = [("val", c_byte)]
diff --git a/Lib/ctypes/test/test_bitfields.py b/Lib/ctypes/test/test_bitfields.py
index 99d8709..54ea839 100644
--- a/Lib/ctypes/test/test_bitfields.py
+++ b/Lib/ctypes/test/test_bitfields.py
@@ -15,7 +15,7 @@ class BITS(Structure):
("G", c_int, 7),
("H", c_int, 8),
("I", c_int, 9),
-
+
("M", c_short, 1),
("N", c_short, 2),
("O", c_short, 3),
@@ -62,7 +62,7 @@ class BitFieldTest(unittest.TestCase):
x = X()
x.a, x.b, x.c = -1, 7, -1
self.failUnlessEqual((x.a, x.b, x.c), (-1, 7, -1))
-
+
def test_ulonglong(self):
class X(Structure):
_fields_ = [("a", c_ulonglong, 1),
@@ -79,7 +79,7 @@ class BitFieldTest(unittest.TestCase):
for c_typ in signed_int_types:
class X(Structure):
_fields_ = [("dummy", c_typ),
- ("a", c_typ, 3),
+ ("a", c_typ, 3),
("b", c_typ, 3),
("c", c_typ, 1)]
self.failUnlessEqual(sizeof(X), sizeof(c_typ)*2)
diff --git a/Lib/ctypes/test/test_buffers.py b/Lib/ctypes/test/test_buffers.py
index 074e854..07527a6 100644
--- a/Lib/ctypes/test/test_buffers.py
+++ b/Lib/ctypes/test/test_buffers.py
@@ -8,14 +8,14 @@ class StringBufferTestCase(unittest.TestCase):
self.failUnlessEqual(len(b), 32)
self.failUnlessEqual(sizeof(b), 32 * sizeof(c_char))
self.failUnless(type(b[0]) is str)
-
+
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.failUnlessEqual(b[0], "a")
self.failUnlessEqual(b[:], "abc\0")
-
+
def test_string_conversion(self):
b = create_string_buffer(u"abc")
self.failUnlessEqual(len(b), 4) # trailing nul char
diff --git a/Lib/ctypes/test/test_byteswap.py b/Lib/ctypes/test/test_byteswap.py
index 81a5f7f..166a5b7 100644
--- a/Lib/ctypes/test/test_byteswap.py
+++ b/Lib/ctypes/test/test_byteswap.py
@@ -11,7 +11,7 @@ def bin(s):
# byte order, and a __ctype_le__ attribute that is the same type in
# LITTLE ENDIAN byte order.
#
-# For Structures and Unions, these types are created on demand.
+# For Structures and Unions, these types are created on demand.
class Test(unittest.TestCase):
def X_test(self):
diff --git a/Lib/ctypes/test/test_callbacks.py b/Lib/ctypes/test/test_callbacks.py
index f9dee78..a6ee150 100644
--- a/Lib/ctypes/test/test_callbacks.py
+++ b/Lib/ctypes/test/test_callbacks.py
@@ -3,7 +3,7 @@ from ctypes import *
import _ctypes_test
class Callbacks(unittest.TestCase):
- functype = CFUNCTYPE
+ functype = CFUNCTYPE
## def tearDown(self):
## import gc
@@ -130,7 +130,7 @@ class SampleCallbacksTestCase(unittest.TestCase):
result = integrate(0.0, 1.0, CALLBACK(func), 10)
diff = abs(result - 1./3.)
-
+
self.failUnless(diff < 0.01, "%s not less than 0.01" % diff)
################################################################
diff --git a/Lib/ctypes/test/test_funcptr.py b/Lib/ctypes/test/test_funcptr.py
index c0b4065..89b93c4 100644
--- a/Lib/ctypes/test/test_funcptr.py
+++ b/Lib/ctypes/test/test_funcptr.py
@@ -122,6 +122,6 @@ class CFuncPtrTestCase(unittest.TestCase):
self.failUnlessEqual(strtok(None, "\n"), "b")
self.failUnlessEqual(strtok(None, "\n"), "c")
self.failUnlessEqual(strtok(None, "\n"), None)
-
+
if __name__ == '__main__':
unittest.main()
diff --git a/Lib/ctypes/test/test_functions.py b/Lib/ctypes/test/test_functions.py
index 6ccb739..435f510 100644
--- a/Lib/ctypes/test/test_functions.py
+++ b/Lib/ctypes/test/test_functions.py
@@ -28,14 +28,14 @@ class FunctionTestCase(unittest.TestCase):
# But in early versions of _ctypes.c, the result of tp_new
# wasn't checked, and it even crashed Python.
# Found by Greg Chapman.
-
+
try:
class X(object, Array):
_length_ = 5
_type_ = "i"
except TypeError:
pass
-
+
from _ctypes import _Pointer
try:
@@ -105,7 +105,7 @@ class FunctionTestCase(unittest.TestCase):
result = f(1, 2, 3, 4, 5.0, 6.0)
self.failUnlessEqual(result, 21)
self.failUnlessEqual(type(result), int)
-
+
result = f(1, 2, 3, 0x10004, 5.0, 6.0)
self.failUnlessEqual(result, 21)
self.failUnlessEqual(type(result), int)
@@ -124,7 +124,7 @@ class FunctionTestCase(unittest.TestCase):
result = f(-1, -2, -3, -4, -5.0, -6.0)
self.failUnlessEqual(result, -21)
self.failUnlessEqual(type(result), float)
-
+
def test_doubleresult(self):
f = dll._testfunc_d_bhilfd
f.argtypes = [c_byte, c_short, c_int, c_long, c_float, c_double]
@@ -136,7 +136,7 @@ class FunctionTestCase(unittest.TestCase):
result = f(-1, -2, -3, -4, -5.0, -6.0)
self.failUnlessEqual(result, -21)
self.failUnlessEqual(type(result), float)
-
+
def test_longlongresult(self):
try:
c_longlong
@@ -226,7 +226,7 @@ class FunctionTestCase(unittest.TestCase):
self.failUnlessEqual(args, expected)
################################################################
-
+
def test_callbacks(self):
f = dll._testfunc_callback_i_if
@@ -237,7 +237,7 @@ class FunctionTestCase(unittest.TestCase):
def callback(value):
#print "called back with", value
return value
-
+
cb = MyCallback(callback)
result = f(-10, cb)
self.failUnlessEqual(result, -18)
@@ -247,7 +247,7 @@ class FunctionTestCase(unittest.TestCase):
cb = MyCallback(callback)
result = f(-10, cb)
self.failUnlessEqual(result, -18)
-
+
AnotherCallback = WINFUNCTYPE(c_int, c_int, c_int, c_int, c_int)
# check that the prototype works: we call f with wrong
@@ -271,7 +271,7 @@ class FunctionTestCase(unittest.TestCase):
#print "called back with", value
self.failUnlessEqual(type(value), int)
return value
-
+
cb = MyCallback(callback)
result = f(-10, cb)
self.failUnlessEqual(result, -18)
diff --git a/Lib/ctypes/test/test_keeprefs.py b/Lib/ctypes/test/test_keeprefs.py
index 5311f98..39e70e3 100644
--- a/Lib/ctypes/test/test_keeprefs.py
+++ b/Lib/ctypes/test/test_keeprefs.py
@@ -130,7 +130,7 @@ class PointerToStructure(unittest.TestCase):
("b", POINTER(POINT))]
r = RECT()
p1 = POINT(1, 2)
-
+
r.a = pointer(p1)
r.b = pointer(p1)
## from pprint import pprint as pp
diff --git a/Lib/ctypes/test/test_macholib.py b/Lib/ctypes/test/test_macholib.py
index f171589..4bb68ac 100644
--- a/Lib/ctypes/test/test_macholib.py
+++ b/Lib/ctypes/test/test_macholib.py
@@ -36,13 +36,13 @@ It'll have output like this:
from ctypes.macholib.dyld import dyld_find
def find_lib(name):
- possible = ['lib'+name+'.dylib', name+'.dylib', name+'.framework/'+name]
- for dylib in possible:
- try:
- return os.path.realpath(dyld_find(dylib))
- except ValueError:
- pass
- raise ValueError, "%s not found" % (name,)
+ possible = ['lib'+name+'.dylib', name+'.dylib', name+'.framework/'+name]
+ for dylib in possible:
+ try:
+ return os.path.realpath(dyld_find(dylib))
+ except ValueError:
+ pass
+ raise ValueError, "%s not found" % (name,)
class MachOTest(unittest.TestCase):
if sys.platform == "darwin":
diff --git a/Lib/ctypes/test/test_numbers.py b/Lib/ctypes/test/test_numbers.py
index 9b4ec73..83003db 100644
--- a/Lib/ctypes/test/test_numbers.py
+++ b/Lib/ctypes/test/test_numbers.py
@@ -34,14 +34,14 @@ except NameError:
else:
unsigned_types.append(c_ulonglong)
signed_types.append(c_longlong)
-
+
unsigned_ranges = valid_ranges(*unsigned_types)
signed_ranges = valid_ranges(*signed_types)
################################################################
class NumberTestCase(unittest.TestCase):
-
+
def test_default_init(self):
# default values are set to zero
for t in signed_types + unsigned_types + float_types:
@@ -132,7 +132,7 @@ class NumberTestCase(unittest.TestCase):
# and alignment of an instance
self.failUnlessEqual((code, alignment(t())),
(code, align))
-
+
def test_int_from_address(self):
from array import array
for t in signed_types + unsigned_types:
@@ -152,7 +152,7 @@ class NumberTestCase(unittest.TestCase):
# changing the value at the memory location changes v's value also
a[0] = 42
self.failUnlessEqual(v.value, a[0])
-
+
def test_float_from_address(self):
from array import array
@@ -168,7 +168,7 @@ class NumberTestCase(unittest.TestCase):
def test_char_from_address(self):
from ctypes import c_char
from array import array
-
+
a = array('c', 'x')
v = c_char.from_address(a.buffer_info()[0])
self.failUnlessEqual(v.value, a[0])
@@ -185,7 +185,7 @@ class NumberTestCase(unittest.TestCase):
## def test_perf(self):
## check_perf()
-
+
from ctypes import _SimpleCData
class c_int_S(_SimpleCData):
_type_ = "i"
@@ -227,7 +227,7 @@ def check_perf():
# c_int(): 3.35 us
# c_int(999): 3.34 us
# c_int_S(): 3.23 us
-# c_int_S(999): 3.24 us
+# c_int_S(999): 3.24 us
# Python 2.2 -OO, win2k, P4 700 MHz:
#
diff --git a/Lib/ctypes/test/test_parameters.py b/Lib/ctypes/test/test_parameters.py
index b788f3a..9537400 100644
--- a/Lib/ctypes/test/test_parameters.py
+++ b/Lib/ctypes/test/test_parameters.py
@@ -18,7 +18,7 @@ class SimpleTypesTestCase(unittest.TestCase):
pass
else:
set_conversion_mode(*self.prev_conv_mode)
-
+
def test_subclasses(self):
from ctypes import c_void_p, c_char_p
diff --git a/Lib/ctypes/test/test_pointers.py b/Lib/ctypes/test/test_pointers.py
index 6b17eda..6172abb 100644
--- a/Lib/ctypes/test/test_pointers.py
+++ b/Lib/ctypes/test/test_pointers.py
@@ -11,7 +11,7 @@ python_types = [int, int, int, int, int, long,
class PointersTestCase(unittest.TestCase):
def test_pointer_crash(self):
-
+
class A(POINTER(c_ulong)):
pass
@@ -84,7 +84,7 @@ class PointersTestCase(unittest.TestCase):
## print self.result
doit(callback)
## print self.result
-
+
def test_basics(self):
from operator import delitem
for ct, pt in zip(ctype_types, python_types):
@@ -132,7 +132,7 @@ class PointersTestCase(unittest.TestCase):
self.assertRaises(TypeError, len, p)
self.failUnlessEqual(p[0], 42)
self.failUnlessEqual(p.contents.value, 42)
-
+
def test_incomplete(self):
lpcell = POINTER("cell")
class cell(Structure):
@@ -166,6 +166,6 @@ class PointersTestCase(unittest.TestCase):
result = func( byref(argc), argv )
assert result == 'world', result
-
+
if __name__ == '__main__':
unittest.main()
diff --git a/Lib/ctypes/test/test_posix.py b/Lib/ctypes/test/test_posix.py
index a13ec1a..2b4fdff 100644
--- a/Lib/ctypes/test/test_posix.py
+++ b/Lib/ctypes/test/test_posix.py
@@ -10,7 +10,7 @@ if os.name == "posix" and sys.platform == "linux2":
def test_GL(self):
cdll.load('libGL.so', mode=RTLD_GLOBAL)
cdll.load('libGLU.so')
-
+
##if os.name == "posix" and sys.platform != "darwin":
## # On platforms where the default shared library suffix is '.so',
diff --git a/Lib/ctypes/test/test_prototypes.py b/Lib/ctypes/test/test_prototypes.py
index ffb113b..2c3d75b 100644
--- a/Lib/ctypes/test/test_prototypes.py
+++ b/Lib/ctypes/test/test_prototypes.py
@@ -44,7 +44,7 @@ class CharPointersTestCase(unittest.TestCase):
func.argtypes = POINTER(c_int),
self.failUnlessEqual(addressof(ci), func(byref(ci)))
-
+
func.argtypes = c_char_p,
self.assertRaises(ArgumentError, func, byref(ci))
@@ -73,7 +73,7 @@ class CharPointersTestCase(unittest.TestCase):
func = testdll._testfunc_p_p
func.restype = c_char_p
func.argtypes = c_char_p,
-
+
self.failUnlessEqual(None, func(None))
self.failUnlessEqual("123", func("123"))
self.failUnlessEqual(None, func(c_char_p(None)))
diff --git a/Lib/ctypes/test/test_refcounts.py b/Lib/ctypes/test/test_refcounts.py
index fb408e6..0c62bf2 100644
--- a/Lib/ctypes/test/test_refcounts.py
+++ b/Lib/ctypes/test/test_refcounts.py
@@ -48,7 +48,7 @@ class RefcountTestCase(unittest.TestCase):
# and may release it again
del f
self.failUnless(grc(func) >= 2)
-
+
# but now it must be gone
gc.collect()
self.failUnless(grc(func) == 2)
@@ -57,14 +57,14 @@ class RefcountTestCase(unittest.TestCase):
_fields_ = [("a", OtherCallback)]
x = X()
x.a = OtherCallback(func)
-
+
# the CFuncPtr instance holds atr least one refcount on func:
self.failUnless(grc(func) > 2)
# and may release it again
del x
self.failUnless(grc(func) >= 2)
-
+
# and now it must be gone again
gc.collect()
self.failUnlessEqual(grc(func), 2)
@@ -80,7 +80,7 @@ class RefcountTestCase(unittest.TestCase):
del f
gc.collect()
self.failUnlessEqual(grc(func), 2)
-
+
class AnotherLeak(unittest.TestCase):
def test_callback(self):
import sys
@@ -89,7 +89,7 @@ class AnotherLeak(unittest.TestCase):
def func(a, b):
return a * b * 2
f = proto(func)
-
+
a = sys.getrefcount(ctypes.c_int)
f(1, 2)
self.failUnlessEqual(sys.getrefcount(ctypes.c_int), a)
diff --git a/Lib/ctypes/test/test_returnfuncptrs.py b/Lib/ctypes/test/test_returnfuncptrs.py
index 3d11c47..ef1f6fd 100644
--- a/Lib/ctypes/test/test_returnfuncptrs.py
+++ b/Lib/ctypes/test/test_returnfuncptrs.py
@@ -16,7 +16,7 @@ class ReturnFuncPtrTestCase(unittest.TestCase):
self.failUnlessEqual(strchr("abcdef", "x"), None)
self.assertRaises(ArgumentError, strchr, "abcdef", 3)
self.assertRaises(TypeError, strchr, "abcdef")
-
+
def test_without_prototype(self):
dll = cdll.load(_ctypes_test.__file__)
get_strchr = dll.get_strchr
diff --git a/Lib/ctypes/test/test_strings.py b/Lib/ctypes/test/test_strings.py
index 3ad0f1d..b507229 100644
--- a/Lib/ctypes/test/test_strings.py
+++ b/Lib/ctypes/test/test_strings.py
@@ -46,7 +46,7 @@ class StringArrayTestCase(unittest.TestCase):
BUF = c_char * 4
buf = BUF()
## print c_char_p.from_param(buf)
-
+
def test_param_2(self):
BUF = c_char * 4
buf = BUF()
@@ -103,9 +103,9 @@ class StringTestCase(unittest.TestCase):
def XX_test_sized_strings(self):
- # New in releases later than 0.4.0:
+ # New in releases later than 0.4.0:
self.assertRaises(TypeError, c_string, None)
-
+
# New in releases later than 0.4.0:
# c_string(number) returns an empty string of size number
self.failUnless(len(c_string(32).raw) == 32)
@@ -181,7 +181,7 @@ else:
# One char too long values:
self.assertRaises(ValueError, setattr, cs, "value", u"1234567")
-
+
def run_test(rep, msg, func, arg):
items = range(rep)
from time import clock
diff --git a/Lib/ctypes/test/test_structures.py b/Lib/ctypes/test/test_structures.py
index c659e8e..b6eaac4 100644
--- a/Lib/ctypes/test/test_structures.py
+++ b/Lib/ctypes/test/test_structures.py
@@ -56,7 +56,7 @@ class StructureTestCase(unittest.TestCase):
"f": c_float,
"d": c_double,
}
-
+
def test_simple_structs(self):
for code, tp in self.formats.items():
class X(Structure):
@@ -90,7 +90,7 @@ class StructureTestCase(unittest.TestCase):
("b", Y)]
self.failUnlessEqual(alignment(SI), max(alignment(Y), alignment(X)))
self.failUnlessEqual(sizeof(SI), calcsize("3s0i 3si 0i"))
-
+
class IS(Structure):
_fields_ = [("b", Y),
("a", X)]
@@ -215,7 +215,7 @@ class StructureTestCase(unittest.TestCase):
# too long
self.assertRaises(ValueError, Person, "1234567", 5)
-
+
def test_keyword_initializers(self):
class POINT(Structure):
_fields_ = [("x", c_int), ("y", c_int)]
@@ -315,7 +315,7 @@ class StructureTestCase(unittest.TestCase):
func(*args)
except Exception, detail:
return detail.__class__, str(detail)
-
+
## def test_subclass_creation(self):
## meta = type(Structure)
@@ -373,4 +373,3 @@ class PointerMemberTestCase(unittest.TestCase):
if __name__ == '__main__':
unittest.main()
-
diff --git a/Lib/ctypes/test/test_win32.py b/Lib/ctypes/test/test_win32.py
index 767e64e..3d0b825 100644
--- a/Lib/ctypes/test/test_win32.py
+++ b/Lib/ctypes/test/test_win32.py
@@ -43,22 +43,22 @@ if sys.platform == "win32":
class Structures(unittest.TestCase):
- def test_struct_by_value(self):
- class POINT(Structure):
- _fields_ = [("x", c_long),
- ("y", c_long)]
-
- class RECT(Structure):
- _fields_ = [("left", c_long),
- ("top", c_long),
- ("right", c_long),
- ("bottom", c_long)]
-
- dll = cdll.load(_ctypes_test.__file__)
-
- pt = POINT(10, 10)
- rect = RECT(0, 0, 20, 20)
- self.failUnlessEqual(1, dll.PointInRect(byref(rect), pt))
+ def test_struct_by_value(self):
+ class POINT(Structure):
+ _fields_ = [("x", c_long),
+ ("y", c_long)]
+
+ class RECT(Structure):
+ _fields_ = [("left", c_long),
+ ("top", c_long),
+ ("right", c_long),
+ ("bottom", c_long)]
+
+ dll = cdll.load(_ctypes_test.__file__)
+
+ pt = POINT(10, 10)
+ rect = RECT(0, 0, 20, 20)
+ self.failUnlessEqual(1, dll.PointInRect(byref(rect), pt))
if __name__ == '__main__':
unittest.main()