I had exactly the same issue with my Django project:
$ python manage test polls.tests
worked fine whereas the following failed with an import error:
$ python manage test polls
$ python manage test
(...)
ImportError: Failed to import test module: mydjango.polls.tests
Traceback (most recent call last):
(...)
ImportError: No module named polls.tests
Check carefully the error message: Django’s test runner tries to import the tests from mydjango.polls.tests where mydjango is the name of the root directory (the container for your project).
I fixed this issue by deleting the __init__.py
file in mydjango directory (at the same level than manage.py file). This directory is not supposed to be a python module and it seems to mess up with Django’s test runner if it is the case.
So just deleting the _init_.py file should fix our problem:
$ rm mydjango/__init__.py