2.times
3.times
so that:
verify(mock, 2.times).foo()
def a():
return 1
b = a()
b
But if you want to add a method to int class you get a nice error:
TypeError: can't set attributes of built-in/extension type 'int'
I went for times(2). We could discuss the best syntax forever and
still whatever we chose, times(x) is still used occasionally.
Here are all the cool ways I considered (and there are probably plenty more):
verify(mock, times(3)).foo()
verify(mock, _3.times).foo()
verify(mock, x3).foo()
verify(mock, x3.times).foo()
verify(mock).foo().times(3)
Yet, I decided to go for good old times(x)
cheers,
Szczepan
verify(mock, times=3).foo()