From 55f5c70e4eb4ef08ac33a83d5db477c4a670f233 Mon Sep 17 00:00:00 2001 From: Anler Hp Date: Tue, 20 May 2014 16:12:17 +0200 Subject: [PATCH] Turning off signals dispatch when testing units Model signals pre_save and post_save will be turned off when running unit tests because they are interfering with the tests. --- tests/unit/conftest.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 tests/unit/conftest.py diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py new file mode 100644 index 00000000..2f8e5e80 --- /dev/null +++ b/tests/unit/conftest.py @@ -0,0 +1,10 @@ +from django.db.models import signals + + +def disconnect_signals(): + signals.pre_save.receivers = [] + signals.post_save.receivers = [] + + +def pytest_runtest_setup(item): + disconnect_signals()