From 56264160a2c8fbbe4e36d7c3f804115b8f2e66a2 Mon Sep 17 00:00:00 2001 From: Jacob Kaplan-Moss Date: Mon, 28 Aug 2006 18:59:54 +0000 Subject: [PATCH] Test database creation/deletion now correctly quotes database names when creating/dropping them. git-svn-id: http://code.djangoproject.com/svn/django/trunk@3673 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/test/utils.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/django/test/utils.py b/django/test/utils.py index 28db46dafd..dd48d95aea 100644 --- a/django/test/utils.py +++ b/django/test/utils.py @@ -1,6 +1,6 @@ import sys, time from django.conf import settings -from django.db import connection, transaction +from django.db import connection, transaction, backend # The prefix to put on the default database name when creating # the test database. @@ -29,7 +29,7 @@ def create_test_db(verbosity=1, autoclobber=False): cursor = connection.cursor() _set_autocommit(connection) try: - cursor.execute("CREATE DATABASE %s" % TEST_DATABASE_NAME) + cursor.execute("CREATE DATABASE %s" % backend.quote_name(TEST_DATABASE_NAME)) except Exception, e: sys.stderr.write("Got an error creating the test database: %s\n" % e) if not autoclobber: @@ -38,10 +38,10 @@ def create_test_db(verbosity=1, autoclobber=False): try: if verbosity >= 1: print "Destroying old test database..." - cursor.execute("DROP DATABASE %s" % TEST_DATABASE_NAME) + cursor.execute("DROP DATABASE %s" % backend.quote_name(TEST_DATABASE_NAME)) if verbosity >= 1: print "Creating test database..." - cursor.execute("CREATE DATABASE %s" % TEST_DATABASE_NAME) + cursor.execute("CREATE DATABASE %s" % backend.quote_name(TEST_DATABASE_NAME)) except Exception, e: sys.stderr.write("Got an error recreating the test database: %s\n" % e) sys.exit(2) @@ -73,6 +73,6 @@ def destroy_test_db(old_database_name, verbosity=1): cursor = connection.cursor() _set_autocommit(connection) time.sleep(1) # To avoid "database is being accessed by other users" errors. - cursor.execute("DROP DATABASE %s" % TEST_DATABASE_NAME) + cursor.execute("DROP DATABASE %s" % backend.quote_name(TEST_DATABASE_NAME)) connection.close()