@@ -82,14 +82,6 @@ def test_typeerror(self):
82
82
self .assertRaises (TypeError , t , "" )
83
83
self .assertRaises (TypeError , t , None )
84
84
85
- @unittest .skip ('test disabled' )
86
- def test_valid_ranges (self ):
87
- # invalid values of the correct type
88
- # raise ValueError (not OverflowError)
89
- for t , (l , h ) in zip (unsigned_types , unsigned_ranges ):
90
- self .assertRaises (ValueError , t , l - 1 )
91
- self .assertRaises (ValueError , t , h + 1 )
92
-
93
85
def test_from_param (self ):
94
86
# the from_param class method attribute always
95
87
# returns PyCArgObject instances
@@ -205,19 +197,6 @@ def test_char_from_address(self):
205
197
a [0 ] = ord ('?' )
206
198
self .assertEqual (v .value , b'?' )
207
199
208
- # array does not support c_bool / 't'
209
- @unittest .skip ('test disabled' )
210
- def test_bool_from_address (self ):
211
- from ctypes import c_bool
212
- from array import array
213
- a = array (c_bool ._type_ , [True ])
214
- v = t .from_address (a .buffer_info ()[0 ])
215
- self .assertEqual (v .value , a [0 ])
216
- self .assertEqual (type (v ) is t )
217
- a [0 ] = False
218
- self .assertEqual (v .value , a [0 ])
219
- self .assertEqual (type (v ) is t )
220
-
221
200
def test_init (self ):
222
201
# c_int() can be initialized from Python's int, and c_int.
223
202
# Not from c_long or so, which seems strange, abc should
@@ -234,62 +213,6 @@ def test_float_overflow(self):
234
213
if (hasattr (t , "__ctype_le__" )):
235
214
self .assertRaises (OverflowError , t .__ctype_le__ , big_int )
236
215
237
- @unittest .skip ('test disabled' )
238
- def test_perf (self ):
239
- check_perf ()
240
-
241
- from ctypes import _SimpleCData
242
- class c_int_S (_SimpleCData ):
243
- _type_ = "i"
244
- __slots__ = []
245
-
246
- def run_test (rep , msg , func , arg = None ):
247
- ## items = [None] * rep
248
- items = range (rep )
249
- from time import perf_counter as clock
250
- if arg is not None :
251
- start = clock ()
252
- for i in items :
253
- func (arg ); func (arg ); func (arg ); func (arg ); func (arg )
254
- stop = clock ()
255
- else :
256
- start = clock ()
257
- for i in items :
258
- func (); func (); func (); func (); func ()
259
- stop = clock ()
260
- print ("%15s: %.2f us" % (msg , ((stop - start )* 1e6 / 5 / rep )))
261
-
262
- def check_perf ():
263
- # Construct 5 objects
264
- from ctypes import c_int
265
-
266
- REP = 200000
267
-
268
- run_test (REP , "int()" , int )
269
- run_test (REP , "int(999)" , int )
270
- run_test (REP , "c_int()" , c_int )
271
- run_test (REP , "c_int(999)" , c_int )
272
- run_test (REP , "c_int_S()" , c_int_S )
273
- run_test (REP , "c_int_S(999)" , c_int_S )
274
-
275
- # Python 2.3 -OO, win2k, P4 700 MHz:
276
- #
277
- # int(): 0.87 us
278
- # int(999): 0.87 us
279
- # c_int(): 3.35 us
280
- # c_int(999): 3.34 us
281
- # c_int_S(): 3.23 us
282
- # c_int_S(999): 3.24 us
283
-
284
- # Python 2.2 -OO, win2k, P4 700 MHz:
285
- #
286
- # int(): 0.89 us
287
- # int(999): 0.89 us
288
- # c_int(): 9.99 us
289
- # c_int(999): 10.02 us
290
- # c_int_S(): 9.87 us
291
- # c_int_S(999): 9.85 us
292
216
293
217
if __name__ == '__main__' :
294
- ## check_perf()
295
218
unittest .main ()
0 commit comments