Test that `where` does not access f_locals and erase values.
()
| 605 | |
| 606 | @skip_win32 |
| 607 | def test_where_erase_value(): |
| 608 | """Test that `where` does not access f_locals and erase values.""" |
| 609 | import pexpect |
| 610 | |
| 611 | env = os.environ.copy() |
| 612 | env["IPY_TEST_SIMPLE_PROMPT"] = "1" |
| 613 | |
| 614 | child = pexpect.spawn( |
| 615 | sys.executable, ["-m", "IPython", "--colors=nocolor"], env=env |
| 616 | ) |
| 617 | child.timeout = 15 * IPYTHON_TESTING_TIMEOUT_SCALE |
| 618 | |
| 619 | child.expect("IPython") |
| 620 | child.expect("\n") |
| 621 | child.expect_exact("In [1]") |
| 622 | |
| 623 | block = dedent( |
| 624 | """ |
| 625 | def simple_f(): |
| 626 | myvar = 1 |
| 627 | print(myvar) |
| 628 | 1/0 |
| 629 | print(myvar) |
| 630 | simple_f() """ |
| 631 | ) |
| 632 | |
| 633 | for line in block.splitlines(): |
| 634 | child.sendline(line) |
| 635 | child.expect_exact(line) |
| 636 | child.expect_exact("ZeroDivisionError") |
| 637 | child.expect_exact("In [2]:") |
| 638 | |
| 639 | child.sendline("%debug") |
| 640 | |
| 641 | ## |
| 642 | child.expect("ipdb>") |
| 643 | |
| 644 | child.sendline("myvar") |
| 645 | child.expect("1") |
| 646 | |
| 647 | ## |
| 648 | child.expect("ipdb>") |
| 649 | |
| 650 | child.sendline("myvar = 2") |
| 651 | |
| 652 | ## |
| 653 | child.expect_exact("ipdb>") |
| 654 | |
| 655 | child.sendline("myvar") |
| 656 | |
| 657 | child.expect_exact("2") |
| 658 | |
| 659 | ## |
| 660 | child.expect("ipdb>") |
| 661 | child.sendline("where") |
| 662 | |
| 663 | ## |
| 664 | child.expect("ipdb>") |