質問

I'm getting an error when trying to run an individual TestCase using django-nose

$ ./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)

Note that when I run $ ./manage.py test someapp it successfully runs all of the TestCases in someapp/tests.py; only when trying to run an individual TestCase does it fail.

役に立ちましたか?

解決

If you're using nose, type in the name of the module (normally tests), a colon, and the test class

manage.py test someapp.tests:SomeTestClass

<path_to_python_module>:<class_name>

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top