尝试使用 django-nose 运行单个 TestCase 时出现错误
$ ./manage.py test someapp.ModelTest
nosetests someapp.ModelTest --nologcapture --verbosity=1
Creating test database for alias 'default'...
E
======================================================================
ERROR: Failure: AttributeError ('module' object has no attribute 'ModelTest')
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/nose/loader.py", line 402, in loadTestsFromName
module = resolve_name(addr.module)
File "/usr/lib/python2.7/site-packages/nose/util.py", line 321, in resolve_name
obj = getattr(obj, part)
AttributeError: 'module' object has no attribute 'ModelTest'
----------------------------------------------------------------------
Ran 1 test in 0.003s
FAILED (errors=1)
请注意,当我运行$ ./manage.py test someapp
它时,它会成功运行 someapp/tests.py 中的所有测试用例;只有在尝试运行单个 TestCase 时才会失败。