[ctypes-commit] ctypes/ctypes/test test_loading.py,NONE,1.1.2.1 test_libc.py,1.1.2.1,1.1.2.2
Brought to you by:
theller
From: Thomas H. <th...@us...> - 2005-12-22 20:35:05
|
Update of /cvsroot/ctypes/ctypes/ctypes/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14956/test Modified Files: Tag: branch_1_0 test_libc.py Added Files: Tag: branch_1_0 test_loading.py Log Message: Added Andreas Degerts library loading code, except for the docs. Index: test_libc.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/Attic/test_libc.py,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** test_libc.py 3 Nov 2005 19:49:19 -0000 1.1.2.1 --- test_libc.py 22 Dec 2005 20:34:57 -0000 1.1.2.2 *************** *** 1,35 **** - import os import sys import unittest from ctypes import * - from ctypes.util import find_library - from ctypes.decorators import cdecl, name_library - - # specify which libraries the decorator has to load. Normally, one - # would use ful so-names to specify exact the library we want. - - if os.name == "nt": - name_library("libc", "msvcrt") - name_library("libm", "msvcrt") - elif os.name == "darwin": - name_library("libc", find_library("c")) - name_library("libm", find_library("m")) - else: - name_library("libc", "libc.so.6") - name_library("libm", find_library("m")) - - # load libraries with cdll magic. I still don't know how to find - # 'libc.so.6' from 'c' on linux, otherwise this could be a lot nicer. - - if os.name == "nt": - libm = libc = cdll.msvcrt - elif sys.platform == "darwin": - libc = cdll.c - libm = cdll.m - else: - libc = CDLL("libc.so.6") - libm = cdll.m class LibTest(unittest.TestCase): --- 1,9 ---- import sys import unittest from ctypes import * + libc = cdll.find('c', False) + libm = cdll.find('m', False) class LibTest(unittest.TestCase): *************** *** 41,45 **** self.failUnlessEqual(libm.sqrt(2.0), math.sqrt(2.0)) ! def test_cdecl_decorator(self): # @ cdecl(c_double, "libm", [c_double]) --- 15,19 ---- self.failUnlessEqual(libm.sqrt(2.0), math.sqrt(2.0)) ! def SKIP_test_cdecl_decorator(self): # @ cdecl(c_double, "libm", [c_double]) *************** *** 63,67 **** self.failUnlessEqual(chars.raw, " ,,aaaadmmmnpppsss\x00") ! def test_qsort_decorator(self): from ctypes.decorators import cdecl, name_library --- 37,41 ---- self.failUnlessEqual(chars.raw, " ,,aaaadmmmnpppsss\x00") ! def SKIP_test_qsort_decorator(self): from ctypes.decorators import cdecl, name_library --- NEW FILE: test_loading.py --- from ctypes import * import unittest import os, StringIO class LoaderTest(unittest.TestCase): unknowndll = "xxrandomnamexx" def test_LoadLibrary(self): if os.name == "nt": name = "msvcrt" elif sys.platform == "darwin": name = "libc.dylib" else: name = "libc.so.6" cdll.LoadLibrary(name) self.assertRaises(OSError, cdll.LoadLibrary, self.unknowndll) def test_LoadLibraryVersion(self): version = "6" name = "c" cdll.LoadLibraryVersion(name, version) if sys.platform == "linux2": # linux uses version, libc 9 should not exist self.assertRaises(OSError, cdll.LoadLibraryVersion, name, "9") self.assertRaises(OSError, cdll.LoadLibraryVersion, self.unknowndll, "") def test_find(self): name = "c" cdll.find(name, False) self.assertRaises(OSError, cdll.find, self.unknowndll) if __name__ == "__main__": unittest.main() |