[Django] テストケース名をTypoしてハマる
2013年1月3日
Djangoのテストを実行して、こういうエラーが出たり..
Traceback (most recent call last):
(..中略..)
File "/xxx/xxx/lib/python2.7/unittest/case.py", line 188, in __init__
testMethod = getattr(self, methodName)
TypeError: getattr(): attribute name must be string
または、こういうエラーが出たら..
Traceback (most recent call last):
(..中略..)
File "/xxx/xxx/lib/python2.7/unittest/case.py", line 191, in __init__
(self.__class__, methodName))
ValueError: no such test method in <class 'someapp.tests.test_forms.HogeForm'>: runTest
とりあえずは、テストケースのクラス名が間違ってないか、
確認すると良いです
自分の場合は、テストケースの名前を、
テスト対象の HogeForm にしてしまって、エラーになっていました
from django.test import TestCase
from someapp.forms import HogeForm
class HogeForm(TestCase): # HogeFormTest と書くつもりだった
def test_success(self):
form = HogeForm()
全然わからなくて、ウン十分ハマった!!!!