|
7 | 7 | 2. Semantic correctness: rewritten code has identical behavior to original |
8 | 8 | 3. Single evaluation: side-effecting expressions are not evaluated multiple times |
9 | 9 | 4. Evaluation order: operands see the values Python would give them |
| 10 | +
|
| 11 | +Two known gaps remain, recorded as strict xfails whose reason starts with a |
| 12 | +group name, so that a change can state which group it closes:: |
| 13 | +
|
| 14 | + introspect-container-literal list/dict/set literals are not decomposed |
| 15 | + introspect-callable-variable a called variable shows <function ...> |
10 | 16 | """ |
11 | 17 |
|
12 | 18 | from __future__ import annotations |
@@ -486,6 +492,23 @@ def f(x): |
486 | 492 | must_contain=["where 6 = ", "(3)"], |
487 | 493 | ) |
488 | 494 |
|
| 495 | + @pytest.mark.xfail( |
| 496 | + strict=True, |
| 497 | + reason="introspect-callable-variable: a called name shows its <function ...> repr", |
| 498 | + ) |
| 499 | + def test_simple_call_clean_name(self) -> None: |
| 500 | + """Ideally the message should show 'f()' not '<function ... at 0x...>()'.""" |
| 501 | + assert_introspects( |
| 502 | + """ |
| 503 | + def check(): |
| 504 | + def f(): |
| 505 | + return 42 |
| 506 | + assert f() == 100 |
| 507 | + """, |
| 508 | + must_contain=["where 42 = f()"], |
| 509 | + must_not_contain=["<function"], |
| 510 | + ) |
| 511 | + |
489 | 512 | def test_method_call_shows_result(self) -> None: |
490 | 513 | assert_introspects( |
491 | 514 | """ |
@@ -624,6 +647,21 @@ def check(): |
624 | 647 | class TestIntrospectionContainerLiteral: |
625 | 648 | """Container literals ([...], {...}, {k:v}).""" |
626 | 649 |
|
| 650 | + @pytest.mark.xfail( |
| 651 | + strict=True, |
| 652 | + reason="introspect-container-literal: list/dict/set literals are not decomposed", |
| 653 | + ) |
| 654 | + def test_list_literal_shows_elements(self) -> None: |
| 655 | + assert_introspects( |
| 656 | + """ |
| 657 | + def check(): |
| 658 | + def f(): |
| 659 | + return 99 |
| 660 | + assert [f(), 2, 3] == [1, 2, 3] |
| 661 | + """, |
| 662 | + must_contain=["where 99 = f()"], |
| 663 | + ) |
| 664 | + |
627 | 665 | def test_list_literal_semantics_preserved(self) -> None: |
628 | 666 | assert_semantically_equivalent(""" |
629 | 667 | def check(): |
@@ -727,6 +765,24 @@ def factory(): |
727 | 765 | must_contain=["where 42 = ", "()"], |
728 | 766 | ) |
729 | 767 |
|
| 768 | + @pytest.mark.xfail( |
| 769 | + strict=True, |
| 770 | + reason="introspect-callable-variable: a called name shows its <function ...> repr", |
| 771 | + ) |
| 772 | + def test_callable_variable_clean_name(self) -> None: |
| 773 | + """Ideally should show 'fn()' not '<function factory at 0x...>()'.""" |
| 774 | + assert_introspects( |
| 775 | + """ |
| 776 | + def check(): |
| 777 | + def factory(): |
| 778 | + return 42 |
| 779 | + fn = factory |
| 780 | + assert fn() == 100 |
| 781 | + """, |
| 782 | + must_contain=["where 42 = fn()"], |
| 783 | + must_not_contain=["<function"], |
| 784 | + ) |
| 785 | + |
730 | 786 |
|
731 | 787 | class TestIntrospectionWalrus: |
732 | 788 | """Walrus operator (:=) — has dedicated visitor.""" |
|
0 commit comments