1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Fixed #1662 -- Added resolver for string-form model references for models that have already been loaded, with tests to validate both forward and backward referenced model names. Light refactoring of model loading to make regression tests behave more like normal model loading. Also clarifies the text of some validation errors.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@3195 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Russell Keith-Magee
2006-06-23 04:37:00 +00:00
parent bc2d8cdbc6
commit 0d4b5b9b4a
6 changed files with 82 additions and 20 deletions

View File

@@ -162,10 +162,11 @@ class TestRunner:
# Initialize the test database.
cursor = connection.cursor()
from django.db.models.loading import load_app
# Install the core always installed apps
for app in ALWAYS_INSTALLED_APPS:
self.output(1, "Installing contrib app %s" % app)
mod = __import__(app + ".models", '', '', [''])
mod = load_app(app)
management.install(mod)
# Run the tests for each test model.
@@ -173,8 +174,7 @@ class TestRunner:
for model_dir, model_name in test_models:
self.output(1, "%s model: Importing" % model_name)
try:
# TODO: Abstract this into a meta.get_app() replacement?
mod = __import__(model_dir + '.' + model_name + '.models', '', '', [''])
mod = load_app(model_dir + '.' + model_name)
except Exception, e:
log_error(model_name, "Error while importing", ''.join(traceback.format_exception(*sys.exc_info())[1:]))
continue