Skip to content

Commit bd1eb4a

Browse files
test(rewrite): record the introspection gaps nothing fixes yet
Two expression types still show a value the rewriter never decomposes: a list/dict/set literal, and a name that happens to hold a callable. Neither has a fix in flight, so they stay strict xfails tagged with a group name; the tests state the message we would want instead. Kept out of the coverage matrix itself so that PR carries only tests that pass, and off the fix branches so each of those lands its own group green.
1 parent 86a550b commit bd1eb4a

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

testing/test_assertrewrite_coverage.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
2. Semantic correctness: rewritten code has identical behavior to original
88
3. Single evaluation: side-effecting expressions are not evaluated multiple times
99
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 ...>
1016
"""
1117

1218
from __future__ import annotations
@@ -486,6 +492,23 @@ def f(x):
486492
must_contain=["where 6 = ", "(3)"],
487493
)
488494

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+
489512
def test_method_call_shows_result(self) -> None:
490513
assert_introspects(
491514
"""
@@ -624,6 +647,21 @@ def check():
624647
class TestIntrospectionContainerLiteral:
625648
"""Container literals ([...], {...}, {k:v})."""
626649

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+
627665
def test_list_literal_semantics_preserved(self) -> None:
628666
assert_semantically_equivalent("""
629667
def check():
@@ -727,6 +765,24 @@ def factory():
727765
must_contain=["where 42 = ", "()"],
728766
)
729767

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+
730786

731787
class TestIntrospectionWalrus:
732788
"""Walrus operator (:=) — has dedicated visitor."""

0 commit comments

Comments
 (0)