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
Incorrect teardown after mocking return value of classmethod implemented in base class #139
Comments
Single test to reproduce the issue:
|
I have also found out that the issue can be fixed by reversing the order in in which
|
Thank you for the detailed bug report! I will take a look at this when I have time. |
@ollipa I investigated what's happening and I found the following, here is the minimal code to reproduce in the tests, with what is happening flexmock(some_module.DerivedClass)
some_module.DerivedClass.should_receive("class_method_with_args")
# Here we created an expectation I will call E1 that has `_local_override` to `True`
# Indeed we created a bound method on `DerivedClass` that copies `SomeClass.class_method_with_args`
some_module.DerivedClass.should_receive("class_method_with_args")
# Here we created an expectation I will call E2 that has `_local_override` to `False`
# Indeed because of E1 `DerivedClass.class_method_with_args` now exists, it's the local override
flexmock_teardown() # This is creating the issues So when E1 is reset in the teardown, we successfully delete the local override Worse, after the teardown, because of the way we restore the method, flexmock now identifies it as a method and not a classmethod, I wonder if this can happen in normal use 🤔 Anyway, we need to be able to convey in E2 that is it still a local override, I was thinking that we could store it in the class in an attribute similar to what we do for the method type, eg. |
@christophe-riolo, that sounds good to me. I didn't really have time to work on this myself but I can take a look at your PR if you implement the fix. |
Following tests should pass
but the second test fails with:
For this issue to happen following conditions must be met:
classmethod
is implemented in base class and derived class is mockedIf everything is done in single test then it works as expected. The failure also does not happen if the mocking of return value is split into separate tests.
This issue started happening with
0.10.5
and is present since then.The text was updated successfully, but these errors were encountered: