@@ -482,8 +482,10 @@ class FastCallTests(unittest.TestCase):
482
482
]
483
483
484
484
# Add all the calling conventions and variants of C callables
485
- def setUp (self ):
486
- _testcapi = import_helper .import_module ("_testcapi" )
485
+ @classmethod
486
+ def setUpClass (cls ):
487
+ if _testcapi is None :
488
+ return
487
489
_instance = _testcapi .MethInstance ()
488
490
for obj , expected_self in (
489
491
(_testcapi , _testcapi ), # module-level function
@@ -492,7 +494,7 @@ def setUp(self):
492
494
(_testcapi .MethClass (), _testcapi .MethClass ), # class method on inst.
493
495
(_testcapi .MethStatic , None ), # static method
494
496
):
495
- self .CALLS_POSARGS .extend ([
497
+ cls .CALLS_POSARGS .extend ([
496
498
(obj .meth_varargs , (1 , 2 ), (expected_self , (1 , 2 ))),
497
499
(obj .meth_varargs_keywords ,
498
500
(1 , 2 ), (expected_self , (1 , 2 ), NULL_OR_EMPTY )),
@@ -506,7 +508,7 @@ def setUp(self):
506
508
(obj .meth_o , (123 , ), (expected_self , 123 )),
507
509
])
508
510
509
- self .CALLS_KWARGS .extend ([
511
+ cls .CALLS_KWARGS .extend ([
510
512
(obj .meth_varargs_keywords ,
511
513
(1 , 2 ), {'x' : 'y' }, (expected_self , (1 , 2 ), {'x' : 'y' })),
512
514
(obj .meth_varargs_keywords ,
@@ -527,6 +529,7 @@ def check_result(self, result, expected):
527
529
expected = (* expected [:- 1 ], result [- 1 ])
528
530
self .assertEqual (result , expected )
529
531
532
+ @unittest .skipIf (_testcapi is None , "requires _testcapi" )
530
533
def test_vectorcall_dict (self ):
531
534
# Test PyObject_VectorcallDict()
532
535
@@ -546,6 +549,7 @@ def test_vectorcall_dict(self):
546
549
result = _testcapi .pyobject_fastcalldict (func , args , kwargs )
547
550
self .check_result (result , expected )
548
551
552
+ @unittest .skipIf (_testcapi is None , "requires _testcapi" )
549
553
def test_vectorcall (self ):
550
554
# Test PyObject_Vectorcall()
551
555
0 commit comments