summaryrefslogtreecommitdiffstats
path: root/Lib/ctypes/test
diff options
context:
space:
mode:
authorThomas Heller <theller@ctypes.org>2006-03-13 10:47:02 (GMT)
committerThomas Heller <theller@ctypes.org>2006-03-13 10:47:02 (GMT)
commita022789ab38c65cae5302f363f1cec92f807e859 (patch)
treeb916f9d5dbd19e00eacb49a5056e30600997c4f9 /Lib/ctypes/test
parentabb903fd54596cba08129a110bc53d9ca21935a9 (diff)
downloadcpython-a022789ab38c65cae5302f363f1cec92f807e859.zip
cpython-a022789ab38c65cae5302f363f1cec92f807e859.tar.gz
cpython-a022789ab38c65cae5302f363f1cec92f807e859.tar.bz2
Plug some refcount leaks when tests are run repeatedly.
Diffstat (limited to 'Lib/ctypes/test')
-rw-r--r--Lib/ctypes/test/test_checkretval.py12
-rw-r--r--Lib/ctypes/test/test_repr.py25
2 files changed, 21 insertions, 16 deletions
diff --git a/Lib/ctypes/test/test_checkretval.py b/Lib/ctypes/test/test_checkretval.py
index 7a9cd22..344d0bc 100644
--- a/Lib/ctypes/test/test_checkretval.py
+++ b/Lib/ctypes/test/test_checkretval.py
@@ -3,16 +3,16 @@ import sys
from ctypes import *
+class CHECKED(c_int):
+ def _check_retval_(value):
+ # Receives a CHECKED instance.
+ return str(value.value)
+ _check_retval_ = staticmethod(_check_retval_)
+
class Test(unittest.TestCase):
def test_checkretval(self):
- class CHECKED(c_int):
- def _check_retval_(value):
- # Receives a CHECKED instance.
- return str(value.value)
- _check_retval_ = staticmethod(_check_retval_)
-
import _ctypes_test
dll = cdll.load(_ctypes_test.__file__)
self.failUnlessEqual(42, dll._testfunc_p_p(42))
diff --git a/Lib/ctypes/test/test_repr.py b/Lib/ctypes/test/test_repr.py
index 450b82f..1044f67 100644
--- a/Lib/ctypes/test/test_repr.py
+++ b/Lib/ctypes/test/test_repr.py
@@ -1,23 +1,28 @@
from ctypes import *
import unittest
-nums = [c_byte, c_short, c_int, c_long, c_longlong,
+subclasses = []
+for base in [c_byte, c_short, c_int, c_long, c_longlong,
c_ubyte, c_ushort, c_uint, c_ulong, c_ulonglong,
- c_float, c_double]
+ c_float, c_double]:
+ class X(base):
+ pass
+ subclasses.append(X)
+
+class X(c_char):
+ pass
+
+# This test checks if the __repr__ is correct for subclasses of simple types
class ReprTest(unittest.TestCase):
def test_numbers(self):
- for typ in nums:
- self.failUnless(repr(typ(42)).startswith(typ.__name__))
- class X(typ):
- pass
- self.failUnlessEqual("<X object at", repr(X(42))[:12])
+ for typ in subclasses:
+ base = typ.__bases__[0]
+ self.failUnless(repr(base(42)).startswith(base.__name__))
+ self.failUnlessEqual("<X object at", repr(typ(42))[:12])
def test_char(self):
self.failUnlessEqual("c_char('x')", repr(c_char('x')))
-
- class X(c_char):
- pass
self.failUnlessEqual("<X object at", repr(X('x'))[:12])
if __name__ == "__main__":