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

Method test_is_running

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

Source from the content-addressed store, hash-verified

2328 self.assertEqual(text.strip(), "<Token.MISSING>")
2329
2330 def test_is_running(self):
2331 def check(interpid, expected):
2332 with self.assertRaisesRegex(InterpreterError, 'unrecognized'):
2333 _interpreters.is_running(interpid, restrict=True)
2334 running = _interpreters.is_running(interpid)
2335 self.assertIs(running, expected)
2336
2337 with self.subTest('from _interpreters (running)'):
2338 interpid = _interpreters.create()
2339 with self.running(interpid):
2340 running = _interpreters.is_running(interpid)
2341 self.assertTrue(running)
2342
2343 with self.subTest('from _interpreters (not running)'):
2344 interpid = _interpreters.create()
2345 running = _interpreters.is_running(interpid)
2346 self.assertFalse(running)
2347
2348 with self.subTest('main'):
2349 interpid, *_ = _interpreters.get_main()
2350 check(interpid, True)
2351
2352 with self.subTest('from C-API (running __main__)'):
2353 with self.interpreter_from_capi() as interpid:
2354 with self.running_from_capi(interpid, main=True):
2355 check(interpid, True)
2356
2357 with self.subTest('from C-API (running, but not __main__)'):
2358 with self.interpreter_from_capi() as interpid:
2359 with self.running_from_capi(interpid, main=False):
2360 check(interpid, False)
2361
2362 with self.subTest('from C-API (not running)'):
2363 with self.interpreter_from_capi() as interpid:
2364 check(interpid, False)
2365
2366 def test_exec(self):
2367 with self.subTest('run script'):

Callers

nothing calls this directly

Calls 9

assertTrueMethod · 0.80
assertFalseMethod · 0.80
interpreter_from_capiMethod · 0.80
running_from_capiMethod · 0.80
checkFunction · 0.50
subTestMethod · 0.45
createMethod · 0.45
runningMethod · 0.45
is_runningMethod · 0.45

Tested by

no test coverage detected