Unable to import 3 modules when running tests

182 views
Skip to first unread message

Mike Cameron

unread,
Oct 2, 2014, 2:38:11 PM10/2/14
to django...@googlegroups.com

I'm doing python manage.py test, but always receive one of the following ImportError messages.

ImportError: No module named 'expressions_regress'
ImportError: No module named 'aggregation'
ImportError: No module named 'migrations'

I have ensured my virtual environment is enabled. I'm on Django 1.7.

Here is my settings.py

"""
Django settings for app project.

For more information on this file, see
https://docs.djangoproject.com/en/1.7/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.7/ref/settings/
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'SECRET_KEY'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

TEMPLATE_DEBUG = True

ALLOWED_HOSTS = ['127.0.0.1']


# Application definition

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'rest_framework',
    'base',
    'api'
)

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

ROOT_URLCONF = 'app.urls'

WSGI_APPLICATION = 'app.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.7/ref/settings/#databases

DATABASES = {
    'default': {
        'NAME': 'DB_NAME',
        'ENGINE': 'sqlserver_ado',
        'HOST': 'DB_HOST',
        'USER': ''
    }
}

# Internationalization
# https://docs.djangoproject.com/en/1.7/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.7/howto/static-files/

STATIC_URL = '/static/'

REST_FRAMEWORK = {
    'PAGINATE_BY': 10,
    'PAGINATE_BY_PARAM': 'page_size',
    'MAX_PAGINATE_BY': 100
}

Full traceback -

$ python manage.py test
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "c:\Python34\lib\site-packages\django\core\management\__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "c:\Python34\lib\site-packages\django\core\management\__init__.py", line 377, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "c:\Python34\lib\site-packages\django\core\management\commands\test.py", line 50, in run_from_argv
    super(Command, self).run_from_argv(argv)
  File "c:\Python34\lib\site-packages\django\core\management\base.py", line 288, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "c:\Python34\lib\site-packages\django\core\management\commands\test.py", line 71, in execute
    super(Command, self).execute(*args, **options)
  File "c:\Python34\lib\site-packages\django\core\management\base.py", line 338, in execute
    output = self.handle(*args, **options)
  File "c:\Python34\lib\site-packages\django\core\management\commands\test.py", line 88, in handle
    failures = test_runner.run_tests(test_labels)
  File "c:\Python34\lib\site-packages\django\test\runner.py", line 147, in run_tests
    old_config = self.setup_databases()
  File "c:\Python34\lib\site-packages\django\test\runner.py", line 109, in setup_databases
    return setup_databases(self.verbosity, self.interactive, **kwargs)
  File "c:\Python34\lib\site-packages\django\test\runner.py", line 299, in setup_databases
    serialize=connection.settings_dict.get("TEST_SERIALIZE", True),
  File "c:\Python34\lib\site-packages\sqlserver_ado\creation.py", line 126, in create_test_db
    self.mark_tests_as_expected_failure(self.connection.features.failing_tests)
  File "c:\Python34\lib\site-packages\sqlserver_ado\creation.py", line 120, in mark_tests_as_expected_failure
    test_case = import_string(test_case_name)
  File "c:\Python34\lib\site-packages\django\utils\module_loading.py", line 26, in import_string
    module = import_module(module_path)
  File "c:\Python34\lib\importlib\__init__.py", line 109, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
  File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
  File "<frozen importlib._bootstrap>", line 2212, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
  File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
  File "<frozen importlib._bootstrap>", line 2224, in _find_and_load_unlocked
ImportError: No module named 'expressions_regress'

Also, for some strange reason Googling all 3 errors I'm getting yields nothing of value.

How can I resolve this?

Mike Cameron

unread,
Oct 3, 2014, 7:41:31 AM10/3/14
to django...@googlegroups.com
Also, I have re-created my virtualenv from scratch, but the error persists.

Collin Anderson

unread,
Oct 3, 2014, 10:17:40 AM10/3/14
to django...@googlegroups.com
So there's no tracebacks for the error messages?

The test runner likes to search for tests in your current directory. Is trying to run code it shouldn't be running?

James Cheong

unread,
Oct 8, 2014, 9:09:45 PM10/8/14
to django...@googlegroups.com
Hi Mike

I've had a similar problem and couldn't find much help online.
But finally found the cause of the problem.
Try this fix: https://bitbucket.org/cramm/django-sqlserver/commits/d3a4e28a2768cb7729e788087889bf32806dfffb
It's pretty much bypassing the import errors.

Hope it helps!
Cheers

Jason Ridenour

unread,
Oct 14, 2014, 2:59:20 PM10/14/14
to django...@googlegroups.com
Are you running on Windows? I noticed you are using django-mssql.

I'm having the same issue you are having - I'm using:
django 1.7
Python 2.7
Windows 7
django-mssql 1.6

I'm thinking it's either an issue with the windows install of django or with django-mssql
Reply all
Reply to author
Forward
0 new messages