【发布时间】:2013-10-30 05:15:49
【问题描述】:
我的视图有一个单元测试
class TestFromAllAdd(TestCase):
fixtures = ['staging_accounts_user.json',
'staging_main_category.json',
'staging_main_dashboard.json',
'staging_main_location.json',
'staging_main_product.json',
'staging_main_shoppinglist.json']
def setUp(self):
self.factory = RequestFactory()
self.c = Client()
self.c.login(username='admin', password='admin')
def from_all_products_html404_test(self):
request = self.factory.post('main/adding_from_all_products', {'product_id': ''})
request.user = User.objects.get(username= 'admin')
response = adding_from_all_products(request)
self.assertEqual(response.status_code, 404)
但是我还有几个带有测试的类,我不能同时运行它们:
python manage.py test main 不运行测试,但如果我运行;
python manage.py test main.TestFromAllAdd.from_all_products_html404_test,运行一项测试;
【问题讨论】:
-
里面有问题吗?最后一句话似乎回答了标题中的内容......
-
问题是我想编写 python manage.py test main 并运行所有测试
-
如果您想在名为“main”的 django 应用程序中运行所有测试,那么
python manage.py test main是正确的方法。你遇到了什么错误?
标签: python django unit-testing