uber/doubles

Creating an expectation with times() implies with_args()

denbeigh2000 opened this issue · 1 comments

When creating an expectation using .exactly(n).times() (with the explicit function invocation), it implies with_args().

So, this expectation:

(expect(PrestoRepository)._more_results_available
    .exactly(3).times()
    .and_return(True, True, False))

will fail if _more_results_available is called with any arguments.

This seems pretty unintuitive to me - I understand times has a property decorator, but the method ought to be a no-op instead of implicitly calling with_args, or it creates some confusing expectation violations.

According to http://doubles.readthedocs.io/en/latest/usage.html#call-counts this is correct behavior.
Correct usage of times here is:

(expect(PrestoRepository)._more_results_available
    .exactly(3).times
    .and_return(True, True, False))

In this case with_args is not implied. As per about I closing this issue. If this still doesn't work for you please feel free to reopen.