@@ -482,8 +482,10 @@ class FastCallTests(unittest.TestCase):
482482 ]
483483
484484# 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
487489_instance = _testcapi .MethInstance ()
488490for obj ,expected_self in (
489491 (_testcapi ,_testcapi ),# module-level function
@@ -492,7 +494,7 @@ def setUp(self):
492494 (_testcapi .MethClass (),_testcapi .MethClass ),# class method on inst.
493495 (_testcapi .MethStatic ,None ),# static method
494496 ):
495- self .CALLS_POSARGS .extend ([
497+ cls .CALLS_POSARGS .extend ([
496498 (obj .meth_varargs , (1 ,2 ), (expected_self , (1 ,2 ))),
497499 (obj .meth_varargs_keywords ,
498500 (1 ,2 ), (expected_self , (1 ,2 ),NULL_OR_EMPTY )),
@@ -506,7 +508,7 @@ def setUp(self):
506508 (obj .meth_o , (123 , ), (expected_self ,123 )),
507509 ])
508510
509- self .CALLS_KWARGS .extend ([
511+ cls .CALLS_KWARGS .extend ([
510512 (obj .meth_varargs_keywords ,
511513 (1 ,2 ), {'x' :'y' }, (expected_self , (1 ,2 ), {'x' :'y' })),
512514 (obj .meth_varargs_keywords ,
@@ -527,6 +529,7 @@ def check_result(self, result, expected):
527529expected = (* expected [:- 1 ],result [- 1 ])
528530self .assertEqual (result ,expected )
529531
532+ @unittest .skipIf (_testcapi is None ,"requires _testcapi" )
530533def test_vectorcall_dict (self ):
531534# Test PyObject_VectorcallDict()
532535
@@ -546,6 +549,7 @@ def test_vectorcall_dict(self):
546549result = _testcapi .pyobject_fastcalldict (func ,args ,kwargs )
547550self .check_result (result ,expected )
548551
552+ @unittest .skipIf (_testcapi is None ,"requires _testcapi" )
549553def test_vectorcall (self ):
550554# Test PyObject_Vectorcall()
551555