mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-28 20:44:03 +03:00
994e1ba927
* Added TEMPLATES setting to tests * Remove deprecated view-string in URL conf * Replace 'urls = ...' in test classes with override_settings('ROOT_URLCONF=...') * Refactor UsingURLPatterns to use override_settings(ROOT_URLCONF=...) style * Get model managers and names in a version-compatible manner. * Apply override_settings to a TestCase, not a mixin class * Use '.callback' property instead of private attributes when inspecting urlpatterns * Pass 'user' to template explicitly * Correct sorting of import statements. * Remove unused TEMPLATE_LOADERS setting, in favor of TEMPLATES. * Remove code style issue * BaseFilter test requires a concrete model * Resolve tox.ini issues * Resolve isort differences between local and tox environments
65 lines
1.8 KiB
Python
65 lines
1.8 KiB
Python
def pytest_configure():
|
|
from django.conf import settings
|
|
|
|
settings.configure(
|
|
DEBUG_PROPAGATE_EXCEPTIONS=True,
|
|
DATABASES={
|
|
'default': {
|
|
'ENGINE': 'django.db.backends.sqlite3',
|
|
'NAME': ':memory:'
|
|
}
|
|
},
|
|
SITE_ID=1,
|
|
SECRET_KEY='not very secret in tests',
|
|
USE_I18N=True,
|
|
USE_L10N=True,
|
|
STATIC_URL='/static/',
|
|
ROOT_URLCONF='tests.urls',
|
|
TEMPLATES=[
|
|
{
|
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
'APP_DIRS': True,
|
|
},
|
|
],
|
|
MIDDLEWARE_CLASSES=(
|
|
'django.middleware.common.CommonMiddleware',
|
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
|
'django.contrib.messages.middleware.MessageMiddleware',
|
|
),
|
|
INSTALLED_APPS=(
|
|
'django.contrib.auth',
|
|
'django.contrib.contenttypes',
|
|
'django.contrib.sessions',
|
|
'django.contrib.sites',
|
|
'django.contrib.staticfiles',
|
|
'rest_framework',
|
|
'rest_framework.authtoken',
|
|
'tests',
|
|
),
|
|
PASSWORD_HASHERS=(
|
|
'django.contrib.auth.hashers.MD5PasswordHasher',
|
|
),
|
|
)
|
|
|
|
# guardian is optional
|
|
try:
|
|
import guardian # NOQA
|
|
except ImportError:
|
|
pass
|
|
else:
|
|
settings.ANONYMOUS_USER_ID = -1
|
|
settings.AUTHENTICATION_BACKENDS = (
|
|
'django.contrib.auth.backends.ModelBackend',
|
|
'guardian.backends.ObjectPermissionBackend',
|
|
)
|
|
settings.INSTALLED_APPS += (
|
|
'guardian',
|
|
)
|
|
|
|
try:
|
|
import django
|
|
django.setup()
|
|
except AttributeError:
|
|
pass
|