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

StubOutWithMock on a MockAnything sometimes succeeds, sometimes fails. #54

Open
GoogleCodeExporter opened this issue Mar 19, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?

1. Create a source file mox_restub.py, with the following contents:

import mox


class MyClass(object):

    def MyFunction():
        pass


m=mox.Mox()

print MyClass.MyFunction    # <unbound method MyClass.MyFunction>

m.StubOutWithMock(MyClass, 'MyFunction')

print MyClass.MyFunction    # <MockAnything instance at 139942970002032>

m.StubOutWithMock(MyClass, 'MyFunction')

print MyClass.MyFunction    # <MockAnything instance at 139942970064208>

m.StubOutWithMock(MyClass, 'MyFunction') 
                            # TypeError: Cannot Mock a MockAnything! Did you
                            # remember to call UnsetStubs in your previous 
                            # test?

2. run python ./mox_restub.py

*****

What is the expected output? What do you see instead?

I expect an exception to be thrown at the second call to StubOutWithMock, since 
MyClass.MyFunction is already a MockAnything that has not been unset with 
UnsetStubs.

Instead, the second call to StubOutWithMock silently succeeds, but the third 
call fails.

*****

What version of the product are you using? On what operating system?

mox: python-mox 0.5.3-1ubuntu5
os:  Ubuntu 12.04.1 LTS

Original issue reported on code.google.com by akes...@google.com on 15 Feb 2013 at 6:42

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

1 participant