我有以下tests.py文件:
from django.test import TestCase
from lxml import etree
import tempfile
import utils
class CreateSurveyFromCsvTextTests(TestCase):
def parsesSurveyPassedInAsCsvAndReturnsXmlRepresentation(self):
text = """"survey",,,,,
,"name","type","label","hint","required"
,"gps","geopoint","Record your current location",,"false"
,"start","start",,,
,"end","end",,,
"settings",
,"form_title"
,"New survey" """
xml = create_survey_from_csv_text(text)
lxml.fromstring(xml)
当我使用python manage.py test
运行模块时,输出为
在0.000秒内进行0次测试
我知道跑步者正在拿起文件,因为如果我导入无效就会引发错误。
为什么没有调用测试?
答案 0 :(得分:1)
测试方法的名称需要以test_
开头。这允许类同时具有您可以编写的测试方法和辅助方法。
因此,您应该将方法重命名为test_parsesSurveyPassedInAsCsvAndReturnsXmlRepresentation
(也可能缩短名称)。