﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
21742	Unable to prevent creation of a database during test runs	yscumc	nobody	"I have two databases set up as follows:


{{{
DATABASES = {
    'default': {
        ...
    },
    'someotherdb': {
        ...
    },
}
}}}

I do not have write access to `someotherdb` and would like to prevent the creation of a test database for `someotherdb` when my tests run. However, this simple scenario doesn't seem to be possible.

I believe Django would would greatly benefit from having another option for the database dict such as the following:
{{{
DATABASES = {
    'default': {
        ...
    },
    'someotherdb': {
        ...
        'TEST_CREATE_DATABASE': False,
    },
}
}}}
If set, `DjangoTestSuiteRunner.setup_databases()` and `DjangoTestSuiteRunner.teardown_databases()` should delete the database from the `django.db.connections` so it cannot be accessed from the unit tests. It should prevent an error from being raised upon trying to run test cases which do not use the read-only database.


----

In an attempted workaround, subclassing `DjangoTestSuiteRunner` as in http://stackoverflow.com/questions/5917587/django-unit-tests-without-a-db doesn't work because I need to use the `default` database in my test. Using this method, if I want to use the `default` database, but not `someotherdb`, I would probably have to copy and paste most of the code from `DjangoTestSuiteRunner.setup_databases()` even after subclasssing `DjangoTestSuiteRunner`. It also doesn't make sense to have to do all this just to prevent a test database from being created.

I then tried the following, but it doesn't seem to work because of perhaps a pesky bug:
{{{
DATABASES = {
    'default': {
        'NAME': 'mydefaultdb',
        ...
    },
    'someotherdb': {
        'NAME': 'theotherdb',
        ...
        'TEST_MIRROR': 'default',
    },
}
}}}
It still connect to the server for `someotherdb` and attempts to open the non-existent database `test_mydefaultdb`, which of course fails because it is supposed to be on the server for `default`."	New feature	new	Testing framework	1.5	Normal				Accepted	0	0	0	0	0	0
