In Django, my code on catching pre_save signal works well. However, in testcases in tests.py, the signal handler cannot receive anything. Is there any hint for this problem?
- It seems that my testcases and signal handler are in different apps. Is this the cause of the problem?
Yes. Each app’s
tests.pyis atomic.importyour signal registration code or connect them manually somewhere in your test to make sure they are listening:(From: Listening to signals, Connecting receiver functions.)