Skip to content

rule_runner.do_not_use_mock has issues with call-by-name rule calls #21785

Open
@ndellosa95

Description

@ndellosa95

Describe the bug
I have a plugin where I use the call-by-name syntax in certain spots where I know the name of the rule call (primarily calls to other rules in the same plugin). I'm working on unit tests for said plugin, and I've run into this when attempting to use rule_runner.do_not_use_mock on these rules that are invoked by name.

/Users/nicholas.dellosa/.cache/pants/named_caches/pex_root/venvs/0/s/8d8cc688/venv/lib/python3.9/site-packages/pants/testutil/rule_runner.py:776: in run_rule_with_mocks
    rule_input = [get(g) for g in res]  # type: ignore[union-attr]
/Users/nicholas.dellosa/.cache/pants/named_caches/pex_root/venvs/0/s/8d8cc688/venv/lib/python3.9/site-packages/pants/testutil/rule_runner.py:776: in <listcomp>
    rule_input = [get(g) for g in res]  # type: ignore[union-attr]
/Users/nicholas.dellosa/.cache/pants/named_caches/pex_root/venvs/0/s/8d8cc688/venv/lib/python3.9/site-packages/pants/testutil/rule_runner.py:744: in get
    provider = next(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

.0 = <list_iterator object at 0x113375c40>

        (
            mock_get.mock
            for mock_get in mock_gets
>           if mock_get.output_type == res.output_type
            and all(
                type(val) in mock_get.input_types
                or (
                    union_membership
                    and any(
                        input_type in union_membership
                        and union_membership.is_member(input_type, val)
                        for input_type in mock_get.input_types
                    )
                )
                for val in res.inputs
            )
        ),
        None,
    )
E   AttributeError: 'coroutine' object has no attribute 'output_type'

Pants version
2.23.0

OS
MacOS

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions