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

call count reset when using returns or throws #32

Closed jonathan-benn closed 6 years ago

jonathan-benn commented 7 years ago
stub = sinon.stub()
stub.onFirstCall().returns('first call')
assert stub() == 'first call'
stub.onSecondCall().returns('second call')
assert stub() == 'second call' # fails, returns 'first call'

Note that this applies to throws as well

jonathan-benn commented 6 years ago

A solution should also pass this test:

stub = sinon.stub()
assert stub() == None
assert stub('A') == None
stub.withArgs('A').onSecondCall().returns('second call!')
assert stub('A') == 'second call!'
assert stub('A') == None
assert stub() == None
jonathan-benn commented 6 years ago

I'm working on this issue next