Skip to content

expand doesn't work with mock.patch.multiple #138

@ArthurGW

Description

@ArthurGW

When using mock.patch.multiple as a decorator (class or test method), the mocks it creates are passed in as keyword arguments to the test function.

Unfortunately, this is not compatible with expand, as the standalone functions that it generates (parameterized.parameterized.param_as_standalone_func.standalone_func) only take unnamed positional arguments.

The simplest fix seems to be to just add unnamed keyword arguments as well:

@wraps(func)
def standalone_func(*a, **k):
    return func(*(a + p.args), **p.kwargs, **k)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions