測試我有Django的測試問題。我開始這個命令來運行測試:Django沒有運行與manage.py測試
$ python manage.py test gastrobook
gastrobook是我的應用程序,塔COMAND會被罰款的Django的文檔,其實它的工作原理,但不運行任何測試,但在tests.py我已經寫了一些測試!這是終端說:
$ python manage.py test gastrobook/
Creating test database for alias 'default'...
----------------------------------------------------------------------
Ran 0 tests in 0.000s
OK
Destroying test database for alias 'default'...
這是我tests.py
from django.test import TestCase from gastrobook.models import * import datetime from django.utils import timezone # Create your tests here. def create_recipe(title,desc,procedimento,pub_date,hard,time,person): return Recipe.objects.create(title=title,desc=desc,procedimento=procedimento,pub_date=pub_date,hard=hard,time=time,person=person) class RecipeTest(TestCase): def setUp(self): create_recipe("cui","dcnjenj","owcjc",timezone.now(),2,"5 ore",2) def hard_no_more_than(self): recipe = Recipe.objects.all() for rec in recipe: self.assertIn(rec.hard,range(1,10))
什麼是您的Django版本? – Zulu 2014-10-05 11:35:24
你可以嘗試沒有結尾的斜線('/')嗎?你必須指定一個Python模塊(帶點('.')作爲分隔符)而不是目錄。 – Zulu 2014-10-05 11:42:22