'Creates a test database, prompting the user for confirmation if the
database already exists. Returns the name of the test database created.'

def create_test_db(self, verbosity=1, autoclobber=False):

    from django.core.management import call_command
    test_database_name = self._get_test_db_name()
    if (verbosity >= 1):
        test_db_repr = ''
        if (verbosity >= 2):
            test_db_repr = ("    ('%s')" % test_database_name)
        print ("Creating    test    database    for    alias    '%s'%s..." % (self.connection.alias, test_db_repr))
    self._create_test_db(verbosity, autoclobber)
    self.connection.close()
    settings.DATABASES[self.connection.alias]['NAME'] = test_database_name
    self.connection.settings_dict['NAME'] = test_database_name
    call_command('syncdb', verbosity=max((verbosity - 1), 0), interactive=False, database=self.connection.alias, load_initial_data=False)
    call_command('flush', verbosity=max((verbosity - 1), 0), interactive=False, database=self.connection.alias)
    from django.core.cache import get_cache
    from django.core.cache.backends.db import BaseDatabaseCache
    for cache_alias in settings.CACHES:
        cache = get_cache(cache_alias)
        if isinstance(cache, BaseDatabaseCache):
            call_command('createcachetable', cache._table, database=self.connection.alias)
    self.connection.cursor()
    return test_database_name
