note35 / sinon

Standalone and test framework agnostic Python test spies, stubs and mocks (pronounced "sigh-non").
BSD 2-Clause "Simplified" License
13 stars 4 forks source link

Missing Spy API functions #14

Open jonathan-benn opened 7 years ago

jonathan-benn commented 7 years ago

Here are some Spy API functions that are still missing:

spy.withArgs()
# Creates a spy that only records calls when the received arguments match those passed
# to withArgs. This is useful to be more expressive in your assertions, where you can access
# the spy with the same call.

spy.printf("format string", [arg1, arg2, ...])
# Returns the passed format string with the following replacements performed:
# %n
#     the name of the spy "spy" by default)
# %c
#     the number of times the spy was called, in words ("once", "twice", etc.)
# %C
#     a list of string representations of the calls to the spy, with each call prefixed by a newline and four
#     spaces
# %t
#     a comma-delimited list of this values the spy was called on
# %n
#     the formatted value of the nth argument passed to printf
# %*
#     a comma-delimited list of the (non-format string) arguments passed to printf 
note35 commented 7 years ago

I have given the explanation here

This might be a little bit complicated to implement, but it's doable.

I have no idea about this to be honest, I have also never used this in SinonJS...

jonathan-benn commented 7 years ago

Ok, I'll update the issue.

Don't worry about printf, it's easy to do with regular expressions.