summaryrefslogtreecommitdiffstats
path: root/Lib/ctypes/test/test_find.py
diff options
context:
space:
mode:
authorZachary Ware <zachary.ware@gmail.com>2014-08-08 18:32:16 (GMT)
committerZachary Ware <zachary.ware@gmail.com>2014-08-08 18:32:16 (GMT)
commit5a794c16d98a12f75b728ff902c410f10f93770f (patch)
treed9f29c5e59cf7fed90e5bf09d8b06f6bc3eda690 /Lib/ctypes/test/test_find.py
parent79a1ffde9b3ae4b7dccdf2a64c6fc7cb7c243211 (diff)
downloadcpython-5a794c16d98a12f75b728ff902c410f10f93770f.zip
cpython-5a794c16d98a12f75b728ff902c410f10f93770f.tar.gz
cpython-5a794c16d98a12f75b728ff902c410f10f93770f.tar.bz2
Issue #22060: Clean up/simplify test_ctypes, use test discovery
Diffstat (limited to 'Lib/ctypes/test/test_find.py')
-rw-r--r--Lib/ctypes/test/test_find.py72
1 files changed, 35 insertions, 37 deletions
diff --git a/Lib/ctypes/test/test_find.py b/Lib/ctypes/test/test_find.py
index d838099..d8cd8ad 100644
--- a/Lib/ctypes/test/test_find.py
+++ b/Lib/ctypes/test/test_find.py
@@ -1,60 +1,58 @@
import unittest
import os
import sys
+import test.support
from ctypes import *
from ctypes.util import find_library
-from ctypes.test import is_resource_enabled
-
-if sys.platform == "win32":
- lib_gl = find_library("OpenGL32")
- lib_glu = find_library("Glu32")
- lib_gle = None
-elif sys.platform == "darwin":
- lib_gl = lib_glu = find_library("OpenGL")
- lib_gle = None
-else:
- lib_gl = find_library("GL")
- lib_glu = find_library("GLU")
- lib_gle = find_library("gle")
-
-## print, for debugging
-if is_resource_enabled("printing"):
- if lib_gl or lib_glu or lib_gle:
- print("OpenGL libraries:")
- for item in (("GL", lib_gl),
- ("GLU", lib_glu),
- ("gle", lib_gle)):
- print("\t", item)
-
# On some systems, loading the OpenGL libraries needs the RTLD_GLOBAL mode.
class Test_OpenGL_libs(unittest.TestCase):
- def setUp(self):
- self.gl = self.glu = self.gle = None
+ @classmethod
+ def setUpClass(cls):
+ lib_gl = lib_glu = lib_gle = None
+ if sys.platform == "win32":
+ lib_gl = find_library("OpenGL32")
+ lib_glu = find_library("Glu32")
+ elif sys.platform == "darwin":
+ lib_gl = lib_glu = find_library("OpenGL")
+ else:
+ lib_gl = find_library("GL")
+ lib_glu = find_library("GLU")
+ lib_gle = find_library("gle")
+
+ ## print, for debugging
+ if test.support.verbose:
+ print("OpenGL libraries:")
+ for item in (("GL", lib_gl),
+ ("GLU", lib_glu),
+ ("gle", lib_gle)):
+ print("\t", item)
+
+ cls.gl = cls.glu = cls.gle = None
if lib_gl:
- self.gl = CDLL(lib_gl, mode=RTLD_GLOBAL)
+ cls.gl = CDLL(lib_gl, mode=RTLD_GLOBAL)
if lib_glu:
- self.glu = CDLL(lib_glu, RTLD_GLOBAL)
+ cls.glu = CDLL(lib_glu, RTLD_GLOBAL)
if lib_gle:
try:
- self.gle = CDLL(lib_gle)
+ cls.gle = CDLL(lib_gle)
except OSError:
pass
- @unittest.skipUnless(lib_gl, 'lib_gl not available')
def test_gl(self):
- if self.gl:
- self.gl.glClearIndex
+ if self.gl is None:
+ self.skipTest('lib_gl not available')
+ self.gl.glClearIndex
- @unittest.skipUnless(lib_glu, 'lib_glu not available')
def test_glu(self):
- if self.glu:
- self.glu.gluBeginCurve
+ if self.glu is None:
+ self.skipTest('lib_glu not available')
+ self.glu.gluBeginCurve
- @unittest.skipUnless(lib_gle, 'lib_gle not available')
def test_gle(self):
- if self.gle:
- self.gle.gleGetJoinStyle
+ if self.gle is None:
+ self.skipTest('lib_gle not available')
+ self.gle.gleGetJoinStyle
# On platforms where the default shared library suffix is '.so',
# at least some libraries can be loaded as attributes of the cdll