1+ import _ctypes_test
2+ import ctypes
13import functools
4+ import gc
5+ import math
26import sys
37import unittest
4- from test import support
5-
6- import ctypes
8+ from _ctypes import CTYPES_MAX_ARGCOUNT
79from ctypes import (CDLL , cdll , Structure , CFUNCTYPE ,
810 ArgumentError , POINTER , sizeof ,
911 c_byte , c_ubyte , c_char , c_char_p ,
1012 c_short , c_ushort , c_int , c_uint ,
1113 c_long , c_longlong , c_ulonglong , c_ulong ,
1214 c_float , c_double , c_longdouble , py_object )
13- from _ctypes import CTYPES_MAX_ARGCOUNT
14- import _ctypes_test
15+ from ctypes . util import find_library
16+ from test import support
1517
1618
1719class Callbacks (unittest .TestCase ):
1820 functype = CFUNCTYPE
1921
2022## def tearDown(self):
21- ## import gc
2223## gc.collect()
2324
2425 def callback (self , * args ):
@@ -81,7 +82,6 @@ def test_ulonglong(self):
8182
8283 def test_float (self ):
8384 # only almost equal: double -> float -> double
84- import math
8585 self .check_type (c_float , math .e )
8686 self .check_type (c_float , - math .e )
8787
@@ -138,7 +138,6 @@ def func(self): pass
138138 def __init__ (self ):
139139 self .v = proto (self .func )
140140
141- import gc
142141 for i in range (32 ):
143142 X ()
144143 gc .collect ()
@@ -147,7 +146,6 @@ def __init__(self):
147146 self .assertEqual (len (live ), 0 )
148147
149148 def test_issue12483 (self ):
150- import gc
151149 class Nasty :
152150 def __del__ (self ):
153151 gc .collect ()
@@ -172,8 +170,6 @@ class StdcallCallbacks(Callbacks):
172170 functype = ctypes .WINFUNCTYPE
173171
174172
175- ################################################################
176-
177173class SampleCallbacksTestCase (unittest .TestCase ):
178174
179175 def test_integrate (self ):
@@ -197,7 +193,6 @@ def func(x):
197193 self .assertLess (diff , 0.01 , "%s not less than 0.01" % diff )
198194
199195 def test_issue_8959_a (self ):
200- from ctypes .util import find_library
201196 libc_path = find_library ("c" )
202197 if not libc_path :
203198 self .skipTest ('could not find libc' )
0 commit comments