0

I'm writing some unit tests for an existing django project that has had no unit tests to date.

When I run the tests from the command line using

  ./manage.py test

I get

Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 341, in execute
    django.setup()
  File "/usr/local/lib/python2.7/site-packages/django/__init__.py", line 27, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/local/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
    app_config = AppConfig.create(entry)
  File "/usr/local/lib/python2.7/site-packages/django/apps/config.py", line 90, in create
    module = import_module(entry)
  File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
ImportError: No module named hijack

Now hijack is actually installed as I can use it from the browser when I run the server using

./manage.py runserver

The contents of manage.py is

#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mtmdjango.settings")

    from django.core.management import execute_from_command_line

    execute_from_command_line(sys.argv)

So ... how I can disable the reference for hijack when running tests or how can I enable hijack to be available under the command line when running tests?

(can someone create and add the tag django-hijack)

Keith John Hutchison
  • 4,955
  • 11
  • 46
  • 64

1 Answers1

0

I worked through the tutorials at

https://docs.djangoproject.com/en/1.10/intro/tutorial01/ through https://docs.djangoproject.com/en/1.10/intro/tutorial05/

It turned out my command line was wrong.

python manage.py test contacts

gives me the output I was expecting.

Keith John Hutchison
  • 4,955
  • 11
  • 46
  • 64