MCPcopy Index your code
hub / github.com/python/cpython / test_call

Method test_call

Lib/test/test_interpreters/test_api.py:2404–2448  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2402 self.assertEqual(exc.msg, 'it worked!')
2403
2404 def test_call(self):
2405 interpid = _interpreters.create()
2406
2407 # Here we focus on basic args and return values.
2408 # See TestInterpreterCall for full operational coverage,
2409 # including supported callables.
2410
2411 with self.subTest('no args, return None'):
2412 func = defs.spam_minimal
2413 res, exc = _interpreters.call(interpid, func)
2414 self.assertIsNone(exc)
2415 self.assertIsNone(res)
2416
2417 with self.subTest('empty args, return None'):
2418 func = defs.spam_minimal
2419 res, exc = _interpreters.call(interpid, func, (), {})
2420 self.assertIsNone(exc)
2421 self.assertIsNone(res)
2422
2423 with self.subTest('no args, return non-None'):
2424 func = defs.script_with_return
2425 res, exc = _interpreters.call(interpid, func)
2426 self.assertIsNone(exc)
2427 self.assertIs(res, True)
2428
2429 with self.subTest('full args, return non-None'):
2430 expected = (1, 2, 3, 4, 5, 6, (7, 8), {'g': 9, 'h': 0})
2431 func = defs.spam_full_args
2432 args = (1, 2, 3, 4, 7, 8)
2433 kwargs = dict(e=5, f=6, g=9, h=0)
2434 res, exc = _interpreters.call(interpid, func, args, kwargs)
2435 self.assertIsNone(exc)
2436 self.assertEqual(res, expected)
2437
2438 with self.subTest('uncaught exception'):
2439 func = defs.spam_raises
2440 res, exc = _interpreters.call(interpid, func)
2441 expected = build_excinfo(
2442 Exception, 'spam!',
2443 # We check these in other tests.
2444 formatted=exc.formatted,
2445 errdisplay=exc.errdisplay,
2446 )
2447 self.assertIsNone(res)
2448 self.assertEqual(exc, expected)
2449
2450 @requires_test_modules
2451 def test_set___main___attrs(self):

Callers

nothing calls this directly

Calls 7

build_excinfoFunction · 0.85
assertIsNoneMethod · 0.80
createMethod · 0.45
subTestMethod · 0.45
callMethod · 0.45
assertIsMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected