You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been decorating my TestCase classes with the mocked_relations decorator. Unfortunately I found that setUp is not patched, and even if it is the scope prevents it from reaching the test methods. Therefore, I have created a mixin which can be used in TestCases to provide mocked_relations in the entire TestCase using start() and stop():
I have been decorating my TestCase classes with the
mocked_relations
decorator. Unfortunately I found that setUp is not patched, and even if it is the scope prevents it from reaching the test methods. Therefore, I have created a mixin which can be used in TestCases to providemocked_relations
in the entire TestCase usingstart()
andstop()
:This works when used like this:
This way you can mock the managers in setUp and for example add to a M2M field, what you add in setUp still exists in the test methods.
I just wanted to share my finding, maybe it's useful for others. If interested I can make a PR to integrate it in the rest of the code, let me know :)
The text was updated successfully, but these errors were encountered: