单位测试用django-芹菜? [英] Unit testing with django-celery?

查看:123
本文介绍了单位测试用django-芹菜?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图提出我们的 django-celery 项目。我已阅读文档中的注释,但它并没有给我一个真正做什么的好主意。我不用担心在实际的守护进程中测试任务,仅仅是我的代码的功能。主要是我想知道:

I am trying to come up with a testing methodology for our django-celery project. I have read the notes in the documentation, but it didn't give me a good idea of what to actually do. I am not worried about testing the tasks in the actual daemons, just the functionality of my code. Mainly I am wondering:


  1. 如何绕过 task.delay()测试(我尝试设置 CELERY_ALWAYS_EAGER = True ,但没有区别)?

  2. 我们如何使用推荐的测试设置(如果这是最好的方法)而不改变我们的settings.py?

  3. 我们还可以使用 manage.py test 还是我们必须使用自定义赛跑者?

  1. How can we bypass task.delay() during the test (I tried setting CELERY_ALWAYS_EAGER = True but it made no difference)?
  2. How do we use the test settings that are recommended (if that is the best way) without actually changing our settings.py?
  3. Can we still use manage.py test or do we have to use a custom runner?

总体来说,芹菜测试的任何提示或提示都将非常有帮助。

Overall any hints or tips for testing with celery would be very helpful.

推荐答案

尝试设置:

BROKER_BACKEND = 'memory'

(感谢 asksol 的评论。)

这篇关于单位测试用django-芹菜?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆