Is there any way to disconect models signals in test mode Django 1.11 ?
Or maybe a way to create an object without ORM to prevent dispaching signal from the post_save
method ?
setup test code
def setUp(self):
#some code
with patch(post_save):
self.instance = Instance.objects.create(fields)
error : AttributeError: 'ModelSignal' object has no attribute 'rsplit'
These signals shouldn't really be mocked, but if you really need to do it, this should work:
from unittest.mock import patch
def test_method(self):
with patch('django.db.models.signals.post_save.send'):
MyObject.objects.create()