test_python_receiver.py

tests/test_python_receiver.py

A Python method's receiver is its first parameter, whatever it is named (R5-CORE D1; 2.0.0).

test_a_staticmethod_has_no_receiver

None test_python_receiver.test_a_staticmethod_has_no_receiver()

A staticmethod's first parameter is an ordinary argument.

tests/test_python_receiver.py:37

Show on the map →

Called by none

Calls _scopes

Checks

  • assert _scopes(src)["helper"] == ("", "item")

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measured
Source · 4 lines
def test_a_staticmethod_has_no_receiver() -> None:
    """@brief A staticmethod's first parameter is an ordinary argument."""
    src = "class Foo:\n    @staticmethod\n    def run(item):\n        item.helper()\n"
    assert _scopes(src)["helper"] == ("", "item")

1 more lines, not shown

Activity · 2 steps
lines 39–39src = "class Foo:\n @staticmethod\n def run(item):\n item.helper()\n"lines 40–40assert _scopes(src)["helper"] == ("", "item")

test_the_first_parameter_is_the_receiver

None test_python_receiver.test_the_first_parameter_is_the_receiver(str receiver)

`<first param>.helper()` is qualified by the enclosing class.

tests/test_python_receiver.py:31

Show on the map →

Called by none

Calls _scopes

Checks

  • assert _scopes(src)["helper"] == ("Foo.helper", "")

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measured
Source · 6 lines
def test_the_first_parameter_is_the_receiver(receiver: str) -> None:
    """@brief `<first param>.helper()` is qualified by the enclosing class."""
    src = f"class Foo:\n    def run({receiver}):\n        {receiver}.helper()\n"
    assert _scopes(src)["helper"] == ("Foo.helper", "")

Activity · 2 steps
lines 33–33src = f"class Foo:\n def run({receiver}):\n {receiver}.helper()\n"lines 34–34assert _scopes(src)["helper"] == ("Foo.helper", "")