Django test runner not finding tests
I had the same issue but my problem was different.
I was getting Ran 0 tests
, as OP.
But it turns out the test methods inside your test class must start with keyword test
to run.
Example:
from django.test import TestCaseclass FooTest(TestCase): def setUp(self): pass def tearDown(self): pass def this_wont_run(self): print 'Fail' def test_this_will(self): print 'Win'
Also the files with your TestCases in them have to start with test
.
If you're using a yourapp/tests
package/style for unittests, make sure there's a __init__.py
in your tests
folder (since that's what makes it a Python module!).
I can run test for specific apps e.g.
python project/manage.py test app_name
but when I run
python project/manage.py test
0 tests was found
Figure out I need to run this in the same directory as manage.py
so the solution would be, cd to project directory and run
python manage.py test