Skip to content

Commit ea72ced

Browse files
Address review: use setUpClass in test_call; don't skip everything
1 parent fde9548 commit ea72ced

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Lib/test/test_call.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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()
488490
for 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):
527529
expected = (*expected[:-1], result[-1])
528530
self.assertEqual(result, expected)
529531

532+
@unittest.skipIf(_testcapi is None, "requires _testcapi")
530533
def test_vectorcall_dict(self):
531534
# Test PyObject_VectorcallDict()
532535

@@ -546,6 +549,7 @@ def test_vectorcall_dict(self):
546549
result = _testcapi.pyobject_fastcalldict(func, args, kwargs)
547550
self.check_result(result, expected)
548551

552+
@unittest.skipIf(_testcapi is None, "requires _testcapi")
549553
def test_vectorcall(self):
550554
# Test PyObject_Vectorcall()
551555

0 commit comments

Comments
 (0)