I started learning Django and am using "Test Driven Web Development with Python" book.
On page 21, the book mentions to test using lists/tests.py.
The book uses the code:
$ python3 manage.py test
to run the test.
However, the manage.py file sits in the upper superlists folder and the tests.py sits in lists folder.
I keep getting an error message saying "ImportError: No module named lists.tests”.
Could someone help me figure this out?
My Django project directory looks like below.
superlists
db.sqlite3
functional_test.py
manage.py
lists
__init__.py
admin.py
models.py
tests.py
views.py
superlists
__init__.py
settings.py
urls.py
wsgi.py
__init__.py
$ python manage.py test
Creating test database for alias 'default'...
E
======================================================================
ERROR: superlists.lists.tests (unittest.loader.ModuleImportFailure)
----------------------------------------------------------------------
ImportError: Failed to import test module: superlists.lists.tests
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/loader.py", line 254, in _find_tests
module = self._get_module_from_name(name)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/loader.py", line 232, in _get_module_from_name
__import__(name)
ImportError: No module named lists.tests
----------------------------------------------------------------------
Ran 1 test in 0.000s
FAILED (errors=1)
Destroying test database for alias 'default'...