diff options
author | Adrian Holovaty <adrian@holovaty.com> | 2007-08-20 01:03:33 +0000 |
---|---|---|
committer | Adrian Holovaty <adrian@holovaty.com> | 2007-08-20 01:03:33 +0000 |
commit | 221f99ed5831b71b7ddb810ec8808a884773ef04 (patch) | |
tree | 807edbb6708a2c0530e22d9cca3b9b0adf5da6f0 /django/test/utils.py | |
parent | d4f218bd91d08ed79fcc67c10f4e1cfc6b221784 (diff) | |
download | django-221f99ed5831b71b7ddb810ec8808a884773ef04.tar.gz |
Refactored quote_name() to DatabaseOperations.quote_name(). Refs #5106
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5967 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/test/utils.py')
-rw-r--r-- | django/test/utils.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/django/test/utils.py b/django/test/utils.py index bc53ef4bfb..79aaa6d2c4 100644 --- a/django/test/utils.py +++ b/django/test/utils.py @@ -118,13 +118,15 @@ def create_test_db(verbosity=1, autoclobber=False): else: TEST_DATABASE_NAME = TEST_DATABASE_PREFIX + settings.DATABASE_NAME + qn = connection.ops.quote_name + # Create the test database and connect to it. We need to autocommit # if the database supports it because PostgreSQL doesn't allow # CREATE/DROP DATABASE statements within transactions. cursor = connection.cursor() _set_autocommit(connection) try: - cursor.execute("CREATE DATABASE %s %s" % (backend.quote_name(TEST_DATABASE_NAME), suffix)) + cursor.execute("CREATE DATABASE %s %s" % (qn(TEST_DATABASE_NAME), suffix)) except Exception, e: sys.stderr.write("Got an error creating the test database: %s\n" % e) if not autoclobber: @@ -133,10 +135,10 @@ def create_test_db(verbosity=1, autoclobber=False): try: if verbosity >= 1: print "Destroying old test database..." - cursor.execute("DROP DATABASE %s" % backend.quote_name(TEST_DATABASE_NAME)) + cursor.execute("DROP DATABASE %s" % qn(TEST_DATABASE_NAME)) if verbosity >= 1: print "Creating test database..." - cursor.execute("CREATE DATABASE %s %s" % (backend.quote_name(TEST_DATABASE_NAME), suffix)) + cursor.execute("CREATE DATABASE %s %s" % (qn(TEST_DATABASE_NAME), suffix)) except Exception, e: sys.stderr.write("Got an error recreating the test database: %s\n" % e) sys.exit(2) @@ -180,5 +182,5 @@ 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" % backend.quote_name(TEST_DATABASE_NAME)) + cursor.execute("DROP DATABASE %s" % connection.ops.quote_name(TEST_DATABASE_NAME)) connection.close() |