test_python_receivers.py

tests/test_python_receivers.py

gh#21 — Python call sites carried no receiver, so nothing about them resolved.

test_a_free_call_carries_neither

None test_python_receivers.test_a_free_call_carries_neither(tmp_path)

THE CONTROL. A bare `identifier` callee has no receiver and no qualifier, and marking one would send a free function down the member-resolution path where a unique name is NOT evidence — the distinction `_ast_record_call_edge` grades everything against.

tests/test_python_receivers.py:111

Show on the map →

Called by none

Calls _sites

Checks

  • assert sites["free_function"][2] == SOURCE_AST
  • assert sites["free_function"][3] == ""
  • assert sites["free_function"][4] == ""

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measured
REQ-DDB-PIPE-011measuredtest_a_free_call_carries_neither → _sites → _ast_parse_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_a_free_call_carries_neither → _sites → _ast_parse_one_file → _ts_language_for → _grammar_available → has_language
Source · 10 lines
def test_a_free_call_carries_neither(tmp_path) -> None:
    """THE CONTROL. A bare `identifier` callee has no receiver and no qualifier, and marking
    one would send a free function down the member-resolution path where a unique name is
    NOT evidence — the distinction `_ast_record_call_edge` grades everything against."""
    sites = _sites(tmp_path)
    assert sites["free_function"][2] == SOURCE_AST
    assert sites["free_function"][3] == ""
    assert sites["free_function"][4] == ""

Activity · 4 steps
lines 115–115sites = _sites(tmp_path)lines 116–116assert sites["free_function"][2] == SOURCE_ASTlines 117–117assert sites["free_function"][3] == ""lines 118–118assert sites["free_function"][4] == ""

test_a_member_call_carries_the_receivers_tail

None test_python_receivers.test_a_member_call_carries_the_receivers_tail(tmp_path)

`self.cache.clear()` is the shape `_narrow_by_receiver` exists for: the receiver is `self.cache`, whose TAIL — `cache` — is the member variable whose declared type the index may hold. Taking the whole text or the root (`self`) would both resolve to the wrong thing, which is the same rule the C `_receiver_tail` records.

tests/test_python_receivers.py:92

Show on the map →

Called by none

Calls _sites

Checks

  • assert "clear" in sites
  • assert sites["clear"][4] == "cache", f"receiver tail should be `cache`: {sites['clear']}"
  • assert sites["clear"][3] == "", "a member call names no class, so it carries no qualifier"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measured
REQ-DDB-PIPE-011measuredtest_a_member_call_carries_the_receivers_tail → _sites → _ast_parse_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_a_member_call_carries_the_receivers_tail → _sites → _ast_parse_one_file → _ts_language_for → _grammar_available → has_language
Source · 11 lines
def test_a_member_call_carries_the_receivers_tail(tmp_path) -> None:
    """`self.cache.clear()` is the shape `_narrow_by_receiver` exists for: the receiver is
    `self.cache`, whose TAIL — `cache` — is the member variable whose declared type the index
    may hold. Taking the whole text or the root (`self`) would both resolve to the wrong
    thing, which is the same rule the C `_receiver_tail` records."""
    sites = _sites(tmp_path)
    assert "clear" in sites
    assert sites["clear"][4] == "cache", f"receiver tail should be `cache`: {sites['clear']}"
    assert sites["clear"][3] == "", "a member call names no class, so it carries no qualifier"

Activity · 4 steps
lines 97–97sites = _sites(tmp_path)lines 98–98assert "clear" in siteslines 99–99assert sites["clear"][4] == "cache", f"receiver tail should be `cache`: {sites['clear']}"lines 100–100assert sites["clear"][3] == "", "a member call names no class, so it carries no qualifier"

test_a_plain_object_call_carries_that_object_as_the_receiver

None test_python_receivers.test_a_plain_object_call_carries_that_object_as_the_receiver(tmp_path)

`other.dispatch()` — receiver is a bare name. It usually denotes a local or a parameter that doxygen does not index, which then fails to resolve later; that is the correct outcome and needs no special case here, exactly as on the C path.

tests/test_python_receivers.py:103

Show on the map →

Called by none

Calls _sites

Checks

  • assert sites["dispatch"][4] == "other"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measured
REQ-DDB-PIPE-011measuredtest_a_plain_object_call_carries_that_object_as_the_receiver → _sites → _ast_parse_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_a_plain_object_call_carries_that_object_as_the_receiver → _sites → _ast_parse_one_file → _ts_language_for → _grammar_available → has_language
Source · 8 lines
def test_a_plain_object_call_carries_that_object_as_the_receiver(tmp_path) -> None:
    """`other.dispatch()` — receiver is a bare name. It usually denotes a local or a
    parameter that doxygen does not index, which then fails to resolve later; that is the
    correct outcome and needs no special case here, exactly as on the C path."""
    sites = _sites(tmp_path)
    assert sites["dispatch"][4] == "other"

Activity · 2 steps
lines 107–107sites = _sites(tmp_path)lines 108–108assert sites["dispatch"][4] == "other"

test_a_self_call_carries_its_enclosing_class_as_a_qualifier

None test_python_receivers.test_a_self_call_carries_its_enclosing_class_as_a_qualifier(tmp_path)

`self.prepare()` names its class exactly — the enclosing one — so this is emitted as a QUALIFIER, not a receiver. That matters because the two take different paths: `_narrow_by_qualifier` RESOLVES a call whose class is written at the site, while `_narrow_by_receiver` only narrows and then still needs the class pinned.

tests/test_python_receivers.py:75

Show on the map →

Called by none

Calls _sites

Checks

  • assert "prepare" in sites, sorted(sites)
  • assert sites["prepare"][3] == "Engine.prepare", (f"a self-call must name its enclosing class: {sites['prepare']}" )
  • assert sites["prepare"][4] == "", "a self-call is a qualifier, not a receiver"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measured
REQ-DDB-PIPE-011measuredtest_a_self_call_carries_its_enclosing_class_as_a_qualifier → _sites → _ast_parse_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_a_self_call_carries_its_enclosing_class_as_a_qualifier → _sites → _ast_parse_one_file → _ts_language_for → _grammar_available → has_language
Source · 17 lines
def test_a_self_call_carries_its_enclosing_class_as_a_qualifier(tmp_path) -> None:
    """`self.prepare()` names its class exactly — the enclosing one — so this is emitted as a
    QUALIFIER, not a receiver. That matters because the two take different paths:
    `_narrow_by_qualifier` RESOLVES a call whose class is written at the site, while
    `_narrow_by_receiver` only narrows and then still needs the class pinned.

    The fixture has a second `prepare` on another class precisely so a bare-tail match would
    be ambiguous and the qualifier has to be what separates them.
    """
    sites = _sites(tmp_path)
    assert "prepare" in sites, sorted(sites)
    assert sites["prepare"][3] == "Engine.prepare", (
        f"a self-call must name its enclosing class: {sites['prepare']}"
    )
    assert sites["prepare"][4] == "", "a self-call is a qualifier, not a receiver"

Activity · 4 steps
lines 84–84sites = _sites(tmp_path)lines 85–85assert "prepare" in sites, sorted(sites)lines 86–88assert sites["prepare"][3] == "Engine.prepare", ( f"a self-call must name its enclosing class: {sites['prepare']}" )lines 89–89assert sites["prepare"][4] == "", "a self-call is a qualifier, not a receiver"

test_the_payload_keeps_the_shape_the_folder_reads

None test_python_receivers.test_the_payload_keeps_the_shape_the_folder_reads(tmp_path)

`_fold_call_payload` reads by INDEX and tolerates a short payload, so the element ORDER has to match the C path's — name, line, source, qualifier, receiver — or a Python site would supply its receiver where the folder expects a qualifier.

tests/test_python_receivers.py:121

Show on the map →

Called by none

Calls _sites, all

Checks

  • assert all(len(s) >= 5 for s in sites.values())
  • assert all(isinstance(s[3], str) and isinstance(s[4], str) for s in sites.values())

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measured
REQ-DDB-PIPE-011measuredtest_the_payload_keeps_the_shape_the_folder_reads → _sites → _ast_parse_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_the_payload_keeps_the_shape_the_folder_reads → _sites → _ast_parse_one_file → _ts_language_for → _grammar_available → has_language
REQ-DDB-WIKI-054inferredtest_the_payload_keeps_the_shape_the_folder_reads → all
Source · 12 lines
def test_the_payload_keeps_the_shape_the_folder_reads(tmp_path) -> None:
    """`_fold_call_payload` reads by INDEX and tolerates a short payload, so the element
    ORDER has to match the C path's — name, line, source, qualifier, receiver — or a Python
    site would supply its receiver where the folder expects a qualifier.

    Asserted as `>= 5` rather than `== 5` for the reason the C sibling gives: the payload is
    cached, so a shorter one from an older build must stay readable and pinning an exact
    arity would make this test the thing that breaks when it legitimately grows.
    """
    sites = _sites(tmp_path)
    assert all(len(s) >= 5 for s in sites.values())
    assert all(isinstance(s[3], str) and isinstance(s[4], str) for s in sites.values())

1 more lines, not shown

Activity · 3 steps
lines 130–130sites = _sites(tmp_path)lines 131–131assert all(len(s) >= 5 for s in sites.values())lines 132–132assert all(isinstance(s[3], str) and isinstance(s[4], str) for s in sites.values())