diff options
author | Zachary Ware <zachary.ware@gmail.com> | 2014-06-13 18:44:39 (GMT) |
---|---|---|
committer | Zachary Ware <zachary.ware@gmail.com> | 2014-06-13 18:44:39 (GMT) |
commit | 9422df0924e79445ad6fa7e89e02513932112276 (patch) | |
tree | 9e92acc1cdaca4c1a2225acb7d543bc8b9efcc00 /Lib/ctypes/test/test_find.py | |
parent | bc7c96b9ea64f4af3cb342725ebdff2abe6058ea (diff) | |
download | cpython-9422df0924e79445ad6fa7e89e02513932112276.zip cpython-9422df0924e79445ad6fa7e89e02513932112276.tar.gz cpython-9422df0924e79445ad6fa7e89e02513932112276.tar.bz2 |
Issue #19493: Refactor ctypes test package.
Skipped tests are now marked as skipped, formerly commented-out or
renamed-so-it-doesn't-look-like-a-test tests are uncommented, properly named,
and unconditionally skipped, some tests that simply didn't run before
are now able to run, and a few are split into multiple methods instead of
skipping via 'return' in the middle of a method. Also, a couple of unused
files are removed completely.
Diffstat (limited to 'Lib/ctypes/test/test_find.py')
-rw-r--r-- | Lib/ctypes/test/test_find.py | 69 |
1 files changed, 35 insertions, 34 deletions
diff --git a/Lib/ctypes/test/test_find.py b/Lib/ctypes/test/test_find.py index c54b69b..d838099 100644 --- a/Lib/ctypes/test/test_find.py +++ b/Lib/ctypes/test/test_find.py @@ -1,4 +1,5 @@ import unittest +import os import sys from ctypes import * from ctypes.util import find_library @@ -40,43 +41,43 @@ class Test_OpenGL_libs(unittest.TestCase): except OSError: pass - if lib_gl: - def test_gl(self): - if self.gl: - self.gl.glClearIndex + @unittest.skipUnless(lib_gl, 'lib_gl not available') + def test_gl(self): + if self.gl: + self.gl.glClearIndex - if lib_glu: - def test_glu(self): - if self.glu: - self.glu.gluBeginCurve + @unittest.skipUnless(lib_glu, 'lib_glu not available') + def test_glu(self): + if self.glu: + self.glu.gluBeginCurve - if lib_gle: - def test_gle(self): - if self.gle: - self.gle.gleGetJoinStyle + @unittest.skipUnless(lib_gle, 'lib_gle not available') + def test_gle(self): + if self.gle: + self.gle.gleGetJoinStyle -##if os.name == "posix" and sys.platform != "darwin": - -## # On platforms where the default shared library suffix is '.so', -## # at least some libraries can be loaded as attributes of the cdll -## # object, since ctypes now tries loading the lib again -## # with '.so' appended of the first try fails. -## # -## # Won't work for libc, unfortunately. OTOH, it isn't -## # needed for libc since this is already mapped into the current -## # process (?) -## # -## # On MAC OSX, it won't work either, because dlopen() needs a full path, -## # and the default suffix is either none or '.dylib'. - -## class LoadLibs(unittest.TestCase): -## def test_libm(self): -## import math -## libm = cdll.libm -## sqrt = libm.sqrt -## sqrt.argtypes = (c_double,) -## sqrt.restype = c_double -## self.assertEqual(sqrt(2), math.sqrt(2)) +# On platforms where the default shared library suffix is '.so', +# at least some libraries can be loaded as attributes of the cdll +# object, since ctypes now tries loading the lib again +# with '.so' appended of the first try fails. +# +# Won't work for libc, unfortunately. OTOH, it isn't +# needed for libc since this is already mapped into the current +# process (?) +# +# On MAC OSX, it won't work either, because dlopen() needs a full path, +# and the default suffix is either none or '.dylib'. +@unittest.skip('test disabled') +@unittest.skipUnless(os.name=="posix" and sys.platform != "darwin", + 'test not suitable for this platform') +class LoadLibs(unittest.TestCase): + def test_libm(self): + import math + libm = cdll.libm + sqrt = libm.sqrt + sqrt.argtypes = (c_double,) + sqrt.restype = c_double + self.assertEqual(sqrt(2), math.sqrt(2)) if __name__ == "__main__": unittest.main() |