Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(90837)

Side by Side Diff: Lib/ctypes/test/test_find.py

Issue 21042: ctypes.util.find_library() should return full pathname instead of filename in linux
Patch Set: Created 3 years, 6 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Doc/library/ctypes.rst ('k') | Lib/ctypes/util.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 import unittest 1 import unittest
2 import os 2 import os
3 import sys 3 import sys
4 import test.support 4 import test.support
5 from ctypes import * 5 from ctypes import *
6 from ctypes.util import find_library 6 from ctypes.util import find_library
7 7
8 # On some systems, loading the OpenGL libraries needs the RTLD_GLOBAL mode. 8 # On some systems, loading the OpenGL libraries needs the RTLD_GLOBAL mode.
9 class Test_OpenGL_libs(unittest.TestCase): 9 class Test_OpenGL_libs(unittest.TestCase):
10 @classmethod 10 @classmethod
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 56
57 def test_glu(self): 57 def test_glu(self):
58 if self.glu is None: 58 if self.glu is None:
59 self.skipTest('lib_glu not available') 59 self.skipTest('lib_glu not available')
60 self.glu.gluBeginCurve 60 self.glu.gluBeginCurve
61 61
62 def test_gle(self): 62 def test_gle(self):
63 if self.gle is None: 63 if self.gle is None:
64 self.skipTest('lib_gle not available') 64 self.skipTest('lib_gle not available')
65 self.gle.gleGetJoinStyle 65 self.gle.gleGetJoinStyle
66
67 def test_abspath(self):
68 lib_gl = lib_glu = lib_gle = None
Martin Panter 2016/02/22 00:45:15 I would change setUpClass() to save all these in c
69 if sys.platform == "win32":
70 lib_gl = find_library("OpenGL32")
71 lib_glu = find_library("Glu32")
72 elif sys.platform == "darwin":
73 lib_gl = lib_glu = find_library("OpenGL")
74 else:
75 lib_gl = find_library("GL")
76 lib_glu = find_library("GLU")
77 lib_gle = find_library("gle")
78
79 if lib_gl:
80 self.assertTrue(os.path.isabs(lib_gl))
81 if lib_glu:
82 self.assertTrue(os.path.isabs(lib_glu))
83 if lib_gle:
84 self.assertTrue(os.path.isabs(lib_gle))
66 85
67 # On platforms where the default shared library suffix is '.so', 86 # On platforms where the default shared library suffix is '.so',
68 # at least some libraries can be loaded as attributes of the cdll 87 # at least some libraries can be loaded as attributes of the cdll
69 # object, since ctypes now tries loading the lib again 88 # object, since ctypes now tries loading the lib again
70 # with '.so' appended of the first try fails. 89 # with '.so' appended of the first try fails.
71 # 90 #
72 # Won't work for libc, unfortunately. OTOH, it isn't 91 # Won't work for libc, unfortunately. OTOH, it isn't
73 # needed for libc since this is already mapped into the current 92 # needed for libc since this is already mapped into the current
74 # process (?) 93 # process (?)
75 # 94 #
76 # On MAC OSX, it won't work either, because dlopen() needs a full path, 95 # On MAC OSX, it won't work either, because dlopen() needs a full path,
77 # and the default suffix is either none or '.dylib'. 96 # and the default suffix is either none or '.dylib'.
78 @unittest.skip('test disabled') 97 @unittest.skip('test disabled')
79 @unittest.skipUnless(os.name=="posix" and sys.platform != "darwin", 98 @unittest.skipUnless(os.name=="posix" and sys.platform != "darwin",
80 'test not suitable for this platform') 99 'test not suitable for this platform')
81 class LoadLibs(unittest.TestCase): 100 class LoadLibs(unittest.TestCase):
82 def test_libm(self): 101 def test_libm(self):
83 import math 102 import math
84 libm = cdll.libm 103 libm = cdll.libm
85 sqrt = libm.sqrt 104 sqrt = libm.sqrt
86 sqrt.argtypes = (c_double,) 105 sqrt.argtypes = (c_double,)
87 sqrt.restype = c_double 106 sqrt.restype = c_double
88 self.assertEqual(sqrt(2), math.sqrt(2)) 107 self.assertEqual(sqrt(2), math.sqrt(2))
89 108
90 if __name__ == "__main__": 109 if __name__ == "__main__":
91 unittest.main() 110 unittest.main()
OLDNEW
« no previous file with comments | « Doc/library/ctypes.rst ('k') | Lib/ctypes/util.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+