Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getCall is not working correctly #4

Closed
jonathan-benn opened this issue Sep 26, 2017 · 3 comments
Closed

getCall is not working correctly #4

jonathan-benn opened this issue Sep 26, 2017 · 3 comments
Labels

Comments

@jonathan-benn
Copy link

spy = sinon.spy()
spy(1)
spy(2)
spy.getCall(0)
spy.getCall(1) # fails with "IndexError: The call queue only contains 1 calls"

I think that getCall is not actually returning a call, but rather returning a queued spy/stub. Every time a new spy or stub is created, a new item is added to the queue, and this new item is what's returned by getCall. What is supposed to happen is that getCall should return the execution of a particular spy or stub. Perhaps args_list should be used by getCall?

@note35
Copy link
Owner

note35 commented Sep 27, 2017

Right, checking args_list and kwargs_list in getCall() will make it work properly. The default return of any getCall(n) will be None.

There is another thing need to consider, there is no class Call in current implementation, I considered to not implement this because of making code simple. All features of spy.call are implemented in Wrapper.py now.

For OOD, you might consider to implement an interface for Wrapper called Call. For sure this is an option.

@note35 note35 added the bug label Sep 27, 2017
@jonathan-benn
Copy link
Author

Over the long term, I think that creating a new class Call is the right direction

@note35
Copy link
Owner

note35 commented Sep 27, 2017

Hi,
I have created a gitter here. About creating class Call, we can discuss in there.

By the way, I highly recommend you to fork a new branch and adding your changes in there. With this way, I can also read your commits and code changes. It will make our discussion clear. Later you can rebase your changes into master. 😄

jonathan-benn pushed a commit to jonathan-benn/sinon that referenced this issue Oct 3, 2017
jonathan-benn pushed a commit to jonathan-benn/sinon that referenced this issue Oct 4, 2017
jonathan-benn pushed a commit to jonathan-benn/sinon that referenced this issue Oct 4, 2017
jonathan-benn pushed a commit to jonathan-benn/sinon that referenced this issue Oct 5, 2017
jonathan-benn pushed a commit to jonathan-benn/sinon that referenced this issue Oct 5, 2017
@note35 note35 closed this as completed in #8 Oct 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants