Opened 8 years ago
Closed 8 years ago
#28475 closed New feature (worksforme)
Allow user to skip test database creation per connection
| Reported by: | Harry Moreno | Owned by: | nobody | 
|---|---|---|---|
| Component: | Testing framework | Version: | dev | 
| Severity: | Normal | Keywords: | |
| Cc: | Adam Johnson | Triage Stage: | Unreviewed | 
| Has patch: | no | Needs documentation: | no | 
| Needs tests: | no | Patch needs improvement: | no | 
| Easy pickings: | no | UI/UX: | no | 
Description (last modified by )
I would like to specify in settings.py DATABASES variable that some database connection should be skipped for test database creation.
something like
# settings.py
DATABASES = {
  'secondary': {
    'TEST':  {
      'CREATE': False
    }
  }
}
This is necessary because my project has multiple database connections, some using a Readonly user on the database. When the test management command runs it attempts to create a test database using readonly credentials and the entire test suite fails. A user should be able to specify if a test database should not be created on a database.
Change History (6)
comment:1 by , 8 years ago
| Cc: | added | 
|---|
comment:2 by , 8 years ago
| Component: | Uncategorized → Testing framework | 
|---|---|
| Type: | Uncategorized → New feature | 
| Version: | 1.11 → master | 
comment:3 by , 8 years ago
| Description: | modified (diff) | 
|---|
comment:4 by , 8 years ago
comment:5 by , 8 years ago
I think a test_settings.py file would work. I just could not find the relevant docs before. https://docs.djangoproject.com/en/1.11/topics/testing/advanced/#using-the-django-test-runner-to-test-reusable-applications
closing.
comment:6 by , 8 years ago
| Resolution: | → worksforme | 
|---|---|
| Status: | new → closed | 
I think the easiest solution is to use a separate test settings file that deletes the unneeded entries from
DATABASES. Any downside to that?