@@ -343,6 +343,8 @@ def _default_unarop_args():
343
343
344
344
def _size_and_check_args ():
345
345
return (
346
+ (42 ,),
347
+ (object (),),
346
348
(DummySequence (),),
347
349
(DummyLen (),),
348
350
(DummyListSubclass (),),
@@ -384,23 +386,23 @@ def _size_and_check_args():
384
386
(DummyDequeLen (),),
385
387
(DummyDequeLen ([1 ,2 ,3 ]),),
386
388
)
387
-
389
+
388
390
class TestAbstractWithNative (object ):
389
391
def test_sequence_check (self ):
390
392
TestSequenceCheck = CPyExtType ("TestSequenceCheck" ,
391
393
"""
392
394
PyObject* test_sq_item(PyObject *a, Py_ssize_t i) {
393
395
return a;
394
396
}
395
- int callCheck(PyObject* a) {
396
- return PySequence_Check(a);
397
+ PyObject* callCheck(PyObject* a) {
398
+ return PyLong_FromLong( PySequence_Check(a) );
397
399
}
398
400
""" ,
399
401
tp_methods = '{"callCheck", (PyCFunction)callCheck, METH_O, ""}' ,
400
402
sq_item = "&test_sq_item" ,
401
403
)
402
404
tester = TestSequenceCheck ()
403
- assert tester .callCheck ("a" )
405
+ assert tester .callCheck (tester )
404
406
405
407
def test_sequence_size (self ):
406
408
TestSequenceSize = CPyExtType ("TestSequenceSize" ,
@@ -416,23 +418,23 @@ def test_sequence_size(self):
416
418
sq_length = "&test_sq_length" ,
417
419
)
418
420
tester = TestSequenceSize ()
419
- assert tester .callSize ("a" ) == 10
421
+ assert tester .callSize (tester ) == 10
420
422
421
423
def test_mapping_check (self ):
422
424
TestMappingCheck = CPyExtType ("TestMappingCheck" ,
423
425
"""
424
426
PyObject* test_mp_subscript(PyObject* a, PyObject* b) {
425
427
return a;
426
428
}
427
- int callCheck(PyObject* a) {
428
- return PyMapping_Check(a);
429
+ PyObject* callCheck(PyObject* a) {
430
+ return PyLong_FromLong( PyMapping_Check(a) );
429
431
}
430
432
""" ,
431
433
tp_methods = '{"callCheck", (PyCFunction)callCheck, METH_O, ""}' ,
432
434
mp_subscript = "&test_mp_subscript" ,
433
435
)
434
436
tester = TestMappingCheck ()
435
- assert tester .callCheck ("a" )
437
+ assert tester .callCheck (tester )
436
438
437
439
def test_mapping_size (self ):
438
440
TestMappingSize = CPyExtType ("TestMappingSize" ,
@@ -448,7 +450,7 @@ def test_mapping_size(self):
448
450
mp_length = "&test_mp_length" ,
449
451
)
450
452
tester = TestMappingSize ()
451
- assert tester .callSize ("a" ) == 11
453
+ assert tester .callSize (tester ) == 11
452
454
453
455
def test_object_size_sq (self ):
454
456
TestObjectSizeSQ = CPyExtType ("TestObjectSizeSQ" ,
@@ -464,7 +466,7 @@ def test_object_size_sq(self):
464
466
sq_length = "&test_sq_length" ,
465
467
)
466
468
tester = TestObjectSizeSQ ()
467
- assert tester .callSize ("a" ) == 12
469
+ assert tester .callSize (tester ) == 12
468
470
469
471
def test_object_size_mp (self ):
470
472
TestObjectSizeMP = CPyExtType ("TestObjectSizeMP" ,
@@ -480,7 +482,7 @@ def test_object_size_mp(self):
480
482
mp_length = "&test_sq_length" ,
481
483
)
482
484
tester = TestObjectSizeMP ()
483
- assert tester .callSize ("abc" ) == 13
485
+ assert tester .callSize (tester ) == 13
484
486
485
487
class TestAbstract (CPyExtTestCase ):
486
488
0 commit comments