Fixed runtests.py problem from [3177] where it assumed you were running the tests from within the tests directory

git-svn-id: http://code.djangoproject.com/svn/django/trunk@3181 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2006-06-20 14:27:44 +00:00
parent 5f47161831
commit 0e92f70602
1 changed files with 6 additions and 6 deletions

View File

@ -24,7 +24,7 @@ REGRESSION_TEST_DIR = os.path.join(os.path.dirname(__file__), REGRESSION_TESTS_D
ALWAYS_INSTALLED_APPS = [ ALWAYS_INSTALLED_APPS = [
'django.contrib.contenttypes', 'django.contrib.contenttypes',
'django.contrib.auth', 'django.contrib.auth',
'django.contrib.sites', 'django.contrib.sites',
'django.contrib.flatpages', 'django.contrib.flatpages',
'django.contrib.redirects', 'django.contrib.redirects',
@ -35,8 +35,8 @@ ALWAYS_INSTALLED_APPS = [
def get_test_models(): def get_test_models():
models = [] models = []
for loc in MODEL_TESTS_DIR_NAME, REGRESSION_TESTS_DIR_NAME: for loc, dirpath in (MODEL_TESTS_DIR_NAME, MODEL_TEST_DIR), (REGRESSION_TESTS_DIR_NAME, REGRESSION_TEST_DIR):
for f in os.listdir(loc): for f in os.listdir(dirpath):
if f.startswith('__init__') or f.startswith('.') or f.startswith('sql'): if f.startswith('__init__') or f.startswith('.') or f.startswith('sql'):
continue continue
models.append((loc, f)) models.append((loc, f))
@ -139,7 +139,7 @@ class TestRunner:
TEST_DATABASE_NAME = ":memory:" TEST_DATABASE_NAME = ":memory:"
else: else:
# Create the test database and connect to it. We need to autocommit # Create the test database and connect to it. We need to autocommit
# if the database supports it because PostgreSQL doesn't allow # if the database supports it because PostgreSQL doesn't allow
# CREATE/DROP DATABASE statements within transactions. # CREATE/DROP DATABASE statements within transactions.
cursor = connection.cursor() cursor = connection.cursor()
self._set_autocommit(connection) self._set_autocommit(connection)
@ -161,7 +161,7 @@ class TestRunner:
# Initialize the test database. # Initialize the test database.
cursor = connection.cursor() cursor = connection.cursor()
# Install the core always installed apps # Install the core always installed apps
for app in ALWAYS_INSTALLED_APPS: for app in ALWAYS_INSTALLED_APPS:
self.output(1, "Installing contrib app %s" % app) self.output(1, "Installing contrib app %s" % app)
@ -265,7 +265,7 @@ class TestRunner:
print "%s error%s:" % (len(error_list), len(error_list) != 1 and 's' or '') print "%s error%s:" % (len(error_list), len(error_list) != 1 and 's' or '')
else: else:
print "All tests passed." print "All tests passed."
def _set_autocommit(self, connection): def _set_autocommit(self, connection):
""" """
Make sure a connection is in autocommit mode. Make sure a connection is in autocommit mode.