﻿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
31886	Django test hits default database while running test - expecting `test_<defaultdatabasename>`	Carlos Leite	nobody	"
# models.py 
{{{
class Disco(models.Model):
    nome = models.CharField('disco', max_length=50)

class Musica(models.Model):
    disco = models.ForeignKey(Disco, on_delete=models.CASCADE)
    nome = models.CharField('nome do disco', max_length=50)
}}}

# forms.py  
{{{
class MusicForm(forms.Form):
     ''' ... like a search form, I need option from database '''
     disco = forms.ChoiceField(choices=Disco.objects.all())   # this cause the error, I dont like it , but supposed its a fair code to have choices.
}}}

# tests.py  
# in the tests.py I just need to import the form to have the odd bahaviour
{{{
from django.test import TestCase
from .forms import MusicForm
}}}

... I just need to import the `MusicForm` to have the erros 
# the error 
{{{
    ...
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
   django.db.utils.OperationalError: FATAL:  database ""disccollection"" does not exist.   <<<-  database should be `test_dis...` <test_something>
}}}

I was trying to run tests, so the database to hit should be  `test_disccollection`
but  not `disccollection` (in my settings.py). 

That may happends because django test framework only changes the settings.database.default alias after my form was initialized I supposed.

The problem I have was in Django 1.8 (Iknow its deprecated) ... then I tried django 3.1 , and error remains 

I got some sample code here -> https://github.com/cadu-leite/django18py2testdb/tree/dj33py3test
"	Bug	closed	Testing framework	3.1	Normal	invalid	settings database test		Unreviewed	0	0	0	0	0	0
