Author: adrian
Date: 2007-02-09 22:01:19 -0600 (Fri, 09 Feb 2007)
New Revision: 4473
Modified:
django/trunk/tests/runtests.py
Log:
Improved runtests.py to normalize MIDDLEWARE_CLASSES during test execution.
Some tests were failing for me because my custom MIDDLEWARE_CLASSES setting
didn't have sessions or authentication installed
Modified: django/trunk/tests/runtests.py
===================================================================
--- django/trunk/tests/runtests.py 2007-02-10 03:56:21 UTC (rev 4472)
+++ django/trunk/tests/runtests.py 2007-02-10 04:01:19 UTC (rev 4473)
@@ -77,13 +77,19 @@
old_root_urlconf = settings.ROOT_URLCONF
old_template_dirs = settings.TEMPLATE_DIRS
old_use_i18n = settings.USE_I18N
+ old_middleware_classes = settings.MIDDLEWARE_CLASSES
- # Redirect some settings for the duration of these tests
+ # Redirect some settings for the duration of these tests.
settings.TEST_DATABASE_NAME = TEST_DATABASE_NAME
settings.INSTALLED_APPS = ALWAYS_INSTALLED_APPS
settings.ROOT_URLCONF = 'urls'
settings.TEMPLATE_DIRS = (os.path.join(os.path.dirname(__file__),
TEST_TEMPLATE_DIR),)
settings.USE_I18N = True
+ settings.MIDDLEWARE_CLASSES = (
+ 'django.contrib.sessions.middleware.SessionMiddleware',
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
+ 'django.middleware.common.CommonMiddleware',
+ )
# Load all the ALWAYS_INSTALLED_APPS.
# (This import statement is intentionally delayed until after we
@@ -91,7 +97,7 @@
from django.db.models.loading import get_apps, load_app
get_apps()
- # Load all the test model apps
+ # Load all the test model apps.
test_models = []
for model_dir, model_name in get_test_models():
model_label = '.'.join([model_dir, model_name])
@@ -109,7 +115,7 @@
sys.stderr.write("Error while importing %s:" % model_name +
''.join(traceback.format_exception(*sys.exc_info())[1:]))
continue
- # Add tests for invalid models
+ # Add tests for invalid models.
extra_tests = []
for model_dir, model_name in get_invalid_models():
model_label = '.'.join([model_dir, model_name])
@@ -120,12 +126,13 @@
from django.test.simple import run_tests
run_tests(test_models, verbosity, extra_tests=extra_tests)
- # Restore the old settings
+ # Restore the old settings.
settings.INSTALLED_APPS = old_installed_apps
settings.TESTS_DATABASE_NAME = old_test_database_name
settings.ROOT_URLCONF = old_root_urlconf
settings.TEMPLATE_DIRS = old_template_dirs
settings.USE_I18N = old_use_i18n
+ settings.MIDDLEWARE_CLASSES = old_middleware_classes
if __name__ == "__main__":
from optparse import OptionParser
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---