When I try to test any app with command (I noticed it when I tried to deploy myproject using fabric, which uses this command):
python manage.py test appname
If database is mysql then these two changes will get the things done.
1.Open mysite/mysite/settings.py
Your database settings should have an additional TEST block as shown with projectname_test.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'myproject',
'USER': 'chandan',
'PASSWORD': 'root',
'HOST': 'localhost',
'PORT': '3306',
'TEST': {
'NAME': 'myproject_test',
},
}
}
2.Type the below command using mysql command prompt or mysql workbench to give all privilages to the user specified in settings.py
GRANT ALL PRIVILEGES ON myproject_test.* TO 'chandan'@'localhost';
Now you can run python manage.py test polls
.