magic-removal: Various cleanup and moving, with respect to the recent django.core.db -> django.db move

git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@1637 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2005-12-14 06:24:32 +00:00
parent 394ad9aa7f
commit aecff3e245
15 changed files with 356 additions and 371 deletions

View file

@ -68,7 +68,7 @@ class TestRunner:
# Manually set INSTALLED_APPS to point to the test models.
settings.INSTALLED_APPS = [MODEL_TESTS_DIR_NAME + '.' + a for a in get_test_models()]
from django.core.db import db
from django.db import connection
from django.core import management
# Determine which models we're going to test.
@ -93,9 +93,9 @@ class TestRunner:
# Create the test database and connect to it. We need autocommit()
# because PostgreSQL doesn't allow CREATE DATABASE statements
# within transactions.
cursor = db.cursor()
cursor = connection.cursor()
try:
db.connection.autocommit(1)
connection.connection.autocommit(1)
except AttributeError:
pass
self.output(1, "Creating test database")
@ -110,12 +110,12 @@ class TestRunner:
else:
print "Tests cancelled."
return
db.close()
connection.close()
old_database_name = settings.DATABASE_NAME
settings.DATABASE_NAME = TEST_DATABASE_NAME
# Initialize the test database.
cursor = db.cursor()
cursor = connection.cursor()
self.output(1, "Initializing test database")
management.init()
@ -145,7 +145,7 @@ class TestRunner:
finally:
# Rollback, in case of database errors. Otherwise they'd have
# side effects on other tests.
db.rollback()
connection.rollback()
if not self.which_tests:
# Run the non-model tests in the other tests dir
@ -178,12 +178,12 @@ class TestRunner:
# to do so, because it's not allowed to delete a database while being
# connected to it.
if settings.DATABASE_ENGINE != "sqlite3":
db.close()
connection.close()
settings.DATABASE_NAME = old_database_name
cursor = db.cursor()
cursor = connection.cursor()
self.output(1, "Deleting test database")
try:
db.connection.autocommit(1)
connection.connection.autocommit(1)
except AttributeError:
pass
else: