(self)
| 369 | interp.id = 1_000_000 |
| 370 | |
| 371 | def test_whence(self): |
| 372 | main = interpreters.get_main() |
| 373 | interp = interpreters.create() |
| 374 | |
| 375 | with self.subTest('main'): |
| 376 | self.assertEqual(main.whence, WHENCE_STR_RUNTIME) |
| 377 | |
| 378 | with self.subTest('from _interpreters'): |
| 379 | self.assertEqual(interp.whence, WHENCE_STR_STDLIB) |
| 380 | |
| 381 | with self.subTest('from C-API'): |
| 382 | text = self.run_temp_from_capi(f""" |
| 383 | import {interpreters.__name__} as interpreters |
| 384 | interp = interpreters.get_current() |
| 385 | print(repr(interp.whence)) |
| 386 | """) |
| 387 | whence = eval(text) |
| 388 | self.assertEqual(whence, WHENCE_STR_CAPI) |
| 389 | |
| 390 | with self.subTest('readonly'): |
| 391 | for value in [ |
| 392 | None, |
| 393 | WHENCE_STR_UNKNOWN, |
| 394 | WHENCE_STR_RUNTIME, |
| 395 | WHENCE_STR_STDLIB, |
| 396 | WHENCE_STR_CAPI, |
| 397 | ]: |
| 398 | with self.assertRaises(AttributeError): |
| 399 | interp.whence = value |
| 400 | with self.assertRaises(AttributeError): |
| 401 | main.whence = value |
| 402 | |
| 403 | def test_hashable(self): |
| 404 | interp = interpreters.create() |
nothing calls this directly
no test coverage detected