summaryrefslogtreecommitdiffstats
path: root/Lib/ctypes
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-03-28 18:38:37 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-03-28 18:38:37 (GMT)
commit9db55004a1bc0c0b3efca69dcd577ff58a86ea16 (patch)
treef54e4634fe90ad07b2a7c7650a2a06d4327fa4ae /Lib/ctypes
parentd7aa5248fb577c7f46d4c0c9b064392bf5c17403 (diff)
downloadcpython-9db55004a1bc0c0b3efca69dcd577ff58a86ea16.zip
cpython-9db55004a1bc0c0b3efca69dcd577ff58a86ea16.tar.gz
cpython-9db55004a1bc0c0b3efca69dcd577ff58a86ea16.tar.bz2
Make some tests more frienly to MemoryError.
Free memory, unlock hanging threads.
Diffstat (limited to 'Lib/ctypes')
-rw-r--r--Lib/ctypes/test/test_find.py14
-rw-r--r--Lib/ctypes/test/test_pointers.py4
2 files changed, 14 insertions, 4 deletions
diff --git a/Lib/ctypes/test/test_find.py b/Lib/ctypes/test/test_find.py
index d8cd8ad..e6bc19d 100644
--- a/Lib/ctypes/test/test_find.py
+++ b/Lib/ctypes/test/test_find.py
@@ -30,15 +30,25 @@ class Test_OpenGL_libs(unittest.TestCase):
cls.gl = cls.glu = cls.gle = None
if lib_gl:
- cls.gl = CDLL(lib_gl, mode=RTLD_GLOBAL)
+ try:
+ cls.gl = CDLL(lib_gl, mode=RTLD_GLOBAL)
+ except OSError:
+ pass
if lib_glu:
- cls.glu = CDLL(lib_glu, RTLD_GLOBAL)
+ try:
+ cls.glu = CDLL(lib_glu, RTLD_GLOBAL)
+ except OSError:
+ pass
if lib_gle:
try:
cls.gle = CDLL(lib_gle)
except OSError:
pass
+ @classmethod
+ def tearDownClass(cls):
+ cls.gl = cls.glu = cls.gle = None
+
def test_gl(self):
if self.gl is None:
self.skipTest('lib_gl not available')
diff --git a/Lib/ctypes/test/test_pointers.py b/Lib/ctypes/test/test_pointers.py
index 4cd3a7a..e24a520 100644
--- a/Lib/ctypes/test/test_pointers.py
+++ b/Lib/ctypes/test/test_pointers.py
@@ -7,8 +7,6 @@ ctype_types = [c_byte, c_ubyte, c_short, c_ushort, c_int, c_uint,
c_long, c_ulong, c_longlong, c_ulonglong, c_double, c_float]
python_types = [int, int, int, int, int, int,
int, int, int, int, float, float]
-LargeNamedType = type('T' * 2 ** 25, (Structure,), {})
-large_string = 'T' * 2 ** 25
class PointersTestCase(unittest.TestCase):
@@ -191,9 +189,11 @@ class PointersTestCase(unittest.TestCase):
self.assertEqual(bool(mth), True)
def test_pointer_type_name(self):
+ LargeNamedType = type('T' * 2 ** 25, (Structure,), {})
self.assertTrue(POINTER(LargeNamedType))
def test_pointer_type_str_name(self):
+ large_string = 'T' * 2 ** 25
self.assertTrue(POINTER(large_string))
if __name__ == '__main__':