Running a test from other folder using manage.py

44 views
Skip to first unread message

Kim

unread,
Jun 8, 2014, 12:48:45 PM6/8/14
to django...@googlegroups.com
Hi everyone,

I have a question on unit tests.
I have manage.py file placed in the upper superlists folder and the tests.py placed in lists folder. 
I keep getting an error message saying "ImportError: No module named lists.tests”. 

Would anyone know how to access a test file from other folder using manage.py?

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

The error message is below:

$ 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'...

Jimish Parekh

unread,
Jun 9, 2014, 4:11:01 AM6/9/14
to django...@googlegroups.com
Hi,
Try running
python manage.py test lists.tests

and see if tests are running or not.

Thanks,

Kimitaka Nakazawa

unread,
Jun 10, 2014, 12:47:05 AM6/10/14
to django...@googlegroups.com
Hi Jimish,

Thank you for the advice. 
I figured that 
$ python manage.py test.views 
worked for me:)

Kind regards,
Kim



--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8624ab0f-c7c8-4e14-8397-06bba9e896e0%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages