Make sure that with lasti pointing to CACHE, it still shows the current line correctly
(self)
| 1450 | |
| 1451 | @cpython_only |
| 1452 | def test_show_currinstr_with_cache(self): |
| 1453 | """ |
| 1454 | Make sure that with lasti pointing to CACHE, it still shows the current |
| 1455 | line correctly |
| 1456 | """ |
| 1457 | def f(): |
| 1458 | print(a) |
| 1459 | # The code above should generate a LOAD_GLOBAL which has CACHE instr after |
| 1460 | # However, this might change in the future. So we explicitly try to find |
| 1461 | # a CACHE entry in the instructions. If we can't do that, fail the test |
| 1462 | |
| 1463 | for inst in _unroll_caches_as_Instructions( |
| 1464 | dis.get_instructions(f, show_caches=True), show_caches=True): |
| 1465 | if inst.opname == "CACHE": |
| 1466 | op_offset = inst.offset - 2 |
| 1467 | cache_offset = inst.offset |
| 1468 | break |
| 1469 | else: |
| 1470 | opname = inst.opname |
| 1471 | else: |
| 1472 | self.fail("Can't find a CACHE entry in the function provided to do the test") |
| 1473 | |
| 1474 | assem_op = self.get_disassembly(f.__code__, lasti=op_offset, wrapper=False) |
| 1475 | assem_cache = self.get_disassembly(f.__code__, lasti=cache_offset, wrapper=False) |
| 1476 | |
| 1477 | # Make sure --> exists and points to the correct op |
| 1478 | self.assertRegex(assem_op, fr"--> {opname}") |
| 1479 | # Make sure when lasti points to cache, it shows the same disassembly |
| 1480 | self.assertEqual(assem_op, assem_cache) |
| 1481 | |
| 1482 | |
| 1483 | class DisWithFileTests(DisTests): |
nothing calls this directly
no test coverage detected