问题描述
我只是遇到了一种奇怪的互动,我很好奇你们中的一个人是否可以解释正在发生的事情:
我正在编写一个测试,开始时,我只是创建了一个简单的打印语句来检查信号是否消失。这是位于notifications/tests/test_notifications.py
中的测试:
def test_like_post_save_signal(self):
""" Testing the signal that is connected to the Like model's post_save. """
baker.make('core.Like')
这是我要测试的信号代码,位于notifcations/notifications.py
中:
@receiver(post_save,sender='core.Like')
def like_signal_post_save(sender,**kwargs):
""" Post save signal for Like model """
print("Something")
幕后发生了一些魔术,但是这里的目标是每次保存Like对象时print("Something")
。
...
现在,这让我感到困惑。我能够使其正常运行,但是只有在将notifications.py
的单独函数导入我的test_notifications.py
文件之后。
这是导入语句:from core.services.notifications.notifications import print_test
为什么使用不同功能(print_test
)的import语句可以访问标准输出?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)