Skip to content

Record multiple calls to spy #378

Closed
Closed
@acroz

Description

@acroz

Hi, I have a use case where I'd like to use mocker.spy() to record all calls to and return values from a callable, however as far as I can tell mocker.spy() only records the most recent call (as spy_return).

Would you welcome a merge request adding this, and if so, do you have any opinions on the API?

I was thinking of something like spy_returns or spy_return_list, which would be a list of return values. I'm not sure how best to handle exceptions - put the return values and exceptions in the same list so the user can determine order, or have two lists? Alternatively just assume that if you're expecting an exception there's less likely to be a need to call it multiple times.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions