如何使用django-nose运行单个测试或单个TestCase?

GDo*_*orn 35 testing django unit-testing nosetests django-nose

使用Django的普通测试运行器,您可以深入研究在特定应用程序,TestCase的特定子类或TestCase的特定子类中的特定测试中运行测试.

例如:

./manage.py test myapp.MyTestCase.test_something
Run Code Online (Sandbox Code Playgroud)

但是,除了测试特定应用程序之外,django-nose似乎不支持任何其他内容.我如何复制最后两个行为?

ale*_*cxe 71

Nose 支持以下语法(:测试脚本名称和测试类名称之间的注释):

./manage.py test myapp.tests.test_script:MyTestCase.test_method
Run Code Online (Sandbox Code Playgroud)

  • 为什么他们不会使用Django标准使用一段时间让我感到野蛮...对我来说似乎很倒退. (7认同)

小智 6

正确的答案是./manage.py test myapp/tests/test_script:MyTestCase.test_method.

在相对路径中使用点对我来说不起作用,但斜线确实如此.