dcramer/mock-django

django.contrib.auth models import

tkhyn opened this issue · 2 comments

When running the tests for django-gm2m, that uses mock-django, against django 1.8, I have the following warnings:

d:\dev\.env\buildout\eggs\django-1.8-py2.7.egg\django\contrib\auth\models.py:41: RemovedInDjango19Warning: Model class django.contrib.auth.models.Permission doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9.
  class Permission(models.Model):

d:\dev\.env\buildout\eggs\django-1.8-py2.7.egg\django\contrib\auth\models.py:98: RemovedInDjango19Warning: Model class django.contrib.auth.models.Group doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9.
  class Group(models.Model):

d:\dev\.env\buildout\eggs\django-1.8-py2.7.egg\django\contrib\auth\models.py:436: RemovedInDjango19Warning: Model class django.contrib.auth.models.User doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9.
  class User(AbstractUser)

This comes from the fact that importing mock_django imports mock_django.http which itself imports django.contrib.auth.models ... which triggers the 3 warnings above (they won't be warnings anymore in django 1.9 though, and will break the test suite) as django.contrib.auth is not in INSTALLED_APPS.

The solution I'd think of would be to drop the from .http import * in __init__.py but it may not be suitable for you.

Thanks for looking at that

T

This is likely resolved with the changes applied from #41.

tkhyn commented

Thanks @bennylope. Unfortunately it did not resolve that issue. __init__ still imports http, which still imports django.contrib.auth.models causing the warnings to be raised with Django 1.8 and the test suite to fail on Django 1.9.