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

stubout on a MockAnything sometimes succeeds, sometimes fails. #31

Open
ivancrneto opened this issue Jan 6, 2024 · 0 comments
Open
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@ivancrneto
Copy link
Owner

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


class MyClass:

    def my_function():
        pass


m=mox.Mox()

print(MyClass.my_function)    # <unbound method MyClass.my_function>

m.stubout(MyClass, 'my_function')

print(MyClass.my_function)    # <MockAnything instance at 139942970002032>

m.stubout(MyClass, 'my_function')

print(MyClass.my_function)    # <MockAnything instance at 139942970064208>

m.stubout(MyClass, 'my_function') 
                            # TypeError: Cannot Mock a MockAnything! Did you
                            # remember to call UnsetStubs in your previous 
                            # test?
  1. run python ./mox_restub.py

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

@ivancrneto ivancrneto added bug Something isn't working good first issue Good for newcomers labels Jan 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant