python - Django Test Runner Not Finding Test Methods -
i upgraded django 1.4 1.9 , realized weird going on tests. here project structure:
project manage.py app/ __init__.py tests/ __init__.py test_mytests.py
the test_mytests.py file looks this:
from django.test import testcase class mytests(testcase): def test_math(self): self.assertequal(2, 2) def test_math_again(self): self.assertequal(3, 3)
the test runner can find of tests when run ./manage.py test app
or ./manage.py test app.tests
. when try running ./manage.py test app.tests.mytests
get:
file "/usr/lib/python2.7/unittest/loader.py", line 100, in loadtestsfromname parent, obj = obj, getattr(obj, part) attributeerror: 'module' object has no attribute 'mytests'
if change test class name test_mytests can run ./manage.py test app.tests.test_mytests
, find tests. reading django docs though , seems file name , class name don't have same. in either case showed above still can't run individual tests this, ./manage.py test app.tests.mytests.test_math
i able run individual tests , test classes, can me here? thanks.
in app.tests.test_mytests
part test_mytests
module name, not class. run test_math
should specify full path method:
python manage.py test app.tests.test_mytests.mytests.test_math
Comments
Post a Comment