Skip to content

Commit

Permalink
Set STATIC_ROOT in test runner settings to make sure the admin tests …
Browse files Browse the repository at this point in the history
…pass. Thanks to Julien Phalip for the report.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16597 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
jezdez committed Aug 12, 2011
1 parent 21705bd commit 4a993fa
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions tests/runtests.py
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/usr/bin/env python #!/usr/bin/env python
import os, subprocess, sys import os
import shutil
import subprocess
import sys
import tempfile


import django.contrib as contrib import django.contrib as contrib
from django.utils import unittest from django.utils import unittest
Expand All @@ -10,9 +14,11 @@


TEST_TEMPLATE_DIR = 'templates' TEST_TEMPLATE_DIR = 'templates'


RUNTESTS_DIR = os.path.dirname(__file__)
CONTRIB_DIR = os.path.dirname(contrib.__file__) CONTRIB_DIR = os.path.dirname(contrib.__file__)
MODEL_TEST_DIR = os.path.join(os.path.dirname(__file__), MODEL_TESTS_DIR_NAME) MODEL_TEST_DIR = os.path.join(RUNTESTS_DIR, MODEL_TESTS_DIR_NAME)
REGRESSION_TEST_DIR = os.path.join(os.path.dirname(__file__), REGRESSION_TESTS_DIR_NAME) REGRESSION_TEST_DIR = os.path.join(RUNTESTS_DIR, REGRESSION_TESTS_DIR_NAME)
TEMP_DIR = tempfile.mkdtemp(prefix='django_')


REGRESSION_SUBDIRS_TO_SKIP = ['locale'] REGRESSION_SUBDIRS_TO_SKIP = ['locale']


Expand Down Expand Up @@ -107,13 +113,15 @@ def setup(verbosity, test_labels):
'LANGUAGE_CODE': settings.LANGUAGE_CODE, 'LANGUAGE_CODE': settings.LANGUAGE_CODE,
'MIDDLEWARE_CLASSES': settings.MIDDLEWARE_CLASSES, 'MIDDLEWARE_CLASSES': settings.MIDDLEWARE_CLASSES,
'STATIC_URL': settings.STATIC_URL, 'STATIC_URL': settings.STATIC_URL,
'STATIC_ROOT': settings.STATIC_ROOT,
} }


# Redirect some settings for the duration of these tests. # Redirect some settings for the duration of these tests.
settings.INSTALLED_APPS = ALWAYS_INSTALLED_APPS settings.INSTALLED_APPS = ALWAYS_INSTALLED_APPS
settings.ROOT_URLCONF = 'urls' settings.ROOT_URLCONF = 'urls'
settings.STATIC_URL = '/static/' settings.STATIC_URL = '/static/'
settings.TEMPLATE_DIRS = (os.path.join(os.path.dirname(__file__), TEST_TEMPLATE_DIR),) settings.STATIC_ROOT = os.path.join(TEMP_DIR, 'static')
settings.TEMPLATE_DIRS = (os.path.join(RUNTESTS_DIR, TEST_TEMPLATE_DIR),)
settings.USE_I18N = True settings.USE_I18N = True
settings.LANGUAGE_CODE = 'en' settings.LANGUAGE_CODE = 'en'
settings.LOGIN_URL = '/accounts/login/' settings.LOGIN_URL = '/accounts/login/'
Expand Down Expand Up @@ -162,6 +170,8 @@ def setup(verbosity, test_labels):


def teardown(state): def teardown(state):
from django.conf import settings from django.conf import settings
# Removing the temporary TEMP_DIR
shutil.rmtree(TEMP_DIR)
# Restore the old settings. # Restore the old settings.
for key, value in state.items(): for key, value in state.items():
setattr(settings, key, value) setattr(settings, key, value)
Expand Down

0 comments on commit 4a993fa

Please sign in to comment.