Created
May 13, 2019 14:57
-
-
Save specialunderwear/5c0998a801a3c709c600fa97edf4b2f3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from contextlib import contextmanager | |
from unittest.mock import patch | |
@contextmanager | |
def fake_autocreated(many_to_many_manager): | |
"Do not give a shit about any intermediate models, just update the relation" | |
with patch.object(many_to_many_manager.through._meta, "auto_created", True): | |
yield many_to_many_manager | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment