我知道如何使用 django 运行特定的测试类:python manage.py test MyApp.MyTestClass
。
我想做的是相反的:运行每一个测试,除了一个特别的。在我看来,这看起来像这样:python manage.py test --ignore=MyApp.MyTestClass
有一个简单的方法吗?
编辑:额外的好处是仍然能够手动运行测试(使用第一个命令)。
该test
命令没有内置的忽略选项。
但是您可以在要排除的类中使用@skip
or装饰器:http: //docs.python.org/2.7/library/unittest.html#unittest.skipIf@skipIf
import unittest
@unittest.skip("skip the test")
class MyTestClass(TestCase):
...
测试命令默认没有忽略选项。你可以试试django-ignoretests。您可以使用安装它
pip install django-ignoretests
您可以通过将它们包含在以下内容中来忽略应用程序IGNORE_TESTS
:
IGNORE_TESTS = (
# Apps to ignore. example : 'django.contrib.auth',
)