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

Cannot stub a whole class #16

Open
jonathan-benn opened this issue Oct 18, 2017 · 2 comments
Open

Cannot stub a whole class #16

jonathan-benn opened this issue Oct 18, 2017 · 2 comments

Comments

@jonathan-benn
Copy link

class C():
    def f2(self, x):
        return x*2
    def f3(self, x):
        return x*3
c = C()
stub = sinon.stub(c) # raises exception
@note35
Copy link
Owner

note35 commented Oct 19, 2017

This feature is not exist in previous version I remember. I have tried to implement this at first, but later I found this feature is not exist in SinonJS old version, thus I skipped it.

What I tried to implement this is used deepcopy whole module before, and it didn't work. Also, I have asked this question on StackOverflow before - https://stackoverflow.com/questions/40283493/how-to-deepcopy-a-module-in-python

I believe this should be a low priority issue, since the effort might be too big by implementing own deepcopy.

stub.__init__ -> module -> deepcopy -> replace all module's function
stub.restore -> replace all module's function again from deepcopy

Do you have any idea about this?

@jonathan-benn
Copy link
Author

This one isn't a very important feature of Sinon.JS, since the author recommends that you only stub one method at a time, as is already supported by Sinon.PY

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants