1
+ import _ctypes_test
2
+ import ctypes
1
3
import functools
4
+ import gc
5
+ import math
2
6
import sys
3
7
import unittest
4
- from test import support
5
-
6
- import ctypes
8
+ from _ctypes import CTYPES_MAX_ARGCOUNT
7
9
from ctypes import (CDLL , cdll , Structure , CFUNCTYPE ,
8
10
ArgumentError , POINTER , sizeof ,
9
11
c_byte , c_ubyte , c_char , c_char_p ,
10
12
c_short , c_ushort , c_int , c_uint ,
11
13
c_long , c_longlong , c_ulonglong , c_ulong ,
12
14
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
15
17
16
18
17
19
class Callbacks (unittest .TestCase ):
18
20
functype = CFUNCTYPE
19
21
20
22
## def tearDown(self):
21
- ## import gc
22
23
## gc.collect()
23
24
24
25
def callback (self , * args ):
@@ -81,7 +82,6 @@ def test_ulonglong(self):
81
82
82
83
def test_float (self ):
83
84
# only almost equal: double -> float -> double
84
- import math
85
85
self .check_type (c_float , math .e )
86
86
self .check_type (c_float , - math .e )
87
87
@@ -138,7 +138,6 @@ def func(self): pass
138
138
def __init__ (self ):
139
139
self .v = proto (self .func )
140
140
141
- import gc
142
141
for i in range (32 ):
143
142
X ()
144
143
gc .collect ()
@@ -147,7 +146,6 @@ def __init__(self):
147
146
self .assertEqual (len (live ), 0 )
148
147
149
148
def test_issue12483 (self ):
150
- import gc
151
149
class Nasty :
152
150
def __del__ (self ):
153
151
gc .collect ()
@@ -172,8 +170,6 @@ class StdcallCallbacks(Callbacks):
172
170
functype = ctypes .WINFUNCTYPE
173
171
174
172
175
- ################################################################
176
-
177
173
class SampleCallbacksTestCase (unittest .TestCase ):
178
174
179
175
def test_integrate (self ):
@@ -197,7 +193,6 @@ def func(x):
197
193
self .assertLess (diff , 0.01 , "%s not less than 0.01" % diff )
198
194
199
195
def test_issue_8959_a (self ):
200
- from ctypes .util import find_library
201
196
libc_path = find_library ("c" )
202
197
if not libc_path :
203
198
self .skipTest ('could not find libc' )
0 commit comments