Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ndellosa95 opened this issue Dec 20, 2024 · 0 comments
Open

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

ndellosa95 opened this issue Dec 20, 2024 · 0 comments
Labels

Comments

@ndellosa95
Copy link
Contributor

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

@ndellosa95 ndellosa95 added the bug label Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant