我有一组可以成功运行的单元测试:./runtests.py wagtail.wagtailcore.tests
我也可以跑:
./runtests.py wagtail.wagtailcore.tests.test_page_privacy
但是如果我只想执行其中一个,我会收到'module' object has no attribute [test_case_name]
我的班级会是这样的:
class TestPagePrivacy(TestCase):
def test_anonymous_user_must_authenticate(self):
所以我认为你可以说:./runtests.py wagtail.wagtailcore.tests.test_page_privacy.test_anonymous_user_must_authenticate
为什么这不起作用?
来自django docs:
https://docs.djangoproject.com/en/1.11/topics/testing/overview/#running-tests
# Run just one test method
$ ./manage.py test animals.tests.AnimalTestCase.test_animals_can_speak
答案 0 :(得分:5)
看起来答案是:
./runtests.py wagtail.wagtailcore.tests.test_page_privacy.TestPagePrivacy.test_anonymous_user_must_authenticate
所以 - 目录/文件名/类名/测试名
答案 1 :(得分:0)
你试过吗
wagtail.wagtailcore.tests.TestPagePrivacy.test_anonymous_user_must_authenticate