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

Method test_idempotent

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

Source from the content-addressed store, hash-verified

207 self.assertNotEqual(current, main)
208
209 def test_idempotent(self):
210 with self.subTest('main'):
211 cur1 = interpreters.get_current()
212 cur2 = interpreters.get_current()
213 self.assertIs(cur1, cur2)
214
215 with self.subTest('subinterpreter'):
216 interp = interpreters.create()
217 out = _run_output(interp, dedent("""
218 from concurrent import interpreters
219 cur = interpreters.get_current()
220 print(id(cur))
221 cur = interpreters.get_current()
222 print(id(cur))
223 """))
224 objid1, objid2 = (int(v) for v in out.splitlines())
225 self.assertEqual(objid1, objid2)
226
227 with self.subTest('per-interpreter'):
228 interp = interpreters.create()
229 out = _run_output(interp, dedent("""
230 from concurrent import interpreters
231 cur = interpreters.get_current()
232 print(id(cur))
233 """))
234 id1 = int(out)
235 id2 = id(interp)
236 self.assertNotEqual(id1, id2)
237
238 @requires_test_modules
239 def test_created_with_capi(self):

Callers

nothing calls this directly

Calls 9

dedentFunction · 0.90
idFunction · 0.85
assertNotEqualMethod · 0.80
_run_outputFunction · 0.70
subTestMethod · 0.45
assertIsMethod · 0.45
createMethod · 0.45
splitlinesMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected