django - Choose test database? -
i'm trying run
./manage.py test
but tells me
got error creating test database: permission denied create database
obviously doesn't have permission create database, i'm on shared server, there's not can that. can create new database through control panel don't think there's way can let django automatically.
so, can't create test database manually , instead tell django flush every time, rather recreating whole thing?
i had similar issue. wanted django bypass creation of test database 1 of instances (it not mirror tough). following mark's suggestion, created custom test runner, follows
django.test.simple import djangotestsuiterunner class bypassabledbdjangotestsuiterunner(djangotestsuiterunner): def setup_databases(self, **kwargs): django.db import connections old_names = [] mirrors = [] alias in connections: connection = connections[alias] # if database test mirror, redirect connection # instead of creating test database. if connection.settings_dict['test_mirror']: mirrors.append((alias, connection)) mirror_alias = connection.settings_dict['test_mirror'] connections._connections[alias] = connections[mirror_alias] elif connection.settings_dict.get('bypass_creation','no') == 'no': old_names.append((connection, connection.settings_dict['name'])) connection.creation.create_test_db(self.verbosity, autoclobber=not self.interactive) return old_names, mirrors
then created dict entry in 1 of databases entries inside settings.py, 'bypass_creation':'yes',
finally, configured new testrunner with
test_runner = 'auth.data.runner.bypassabledbdjangotestsuiterunner'
Comments
Post a Comment