1👍
This is because Django loads the settings.py file for running the test suite. You can create a separate settings.py file and use it at the time you run the tests. As an example from the django site:
--settings=test_sqlite
assuming you had a settings.py file called test_sqlite.
Go here for more information:
https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/unit-tests/
1👍
If you run tests frequently put the following code in your settings.py:
import sys
if 'test' in sys.argv:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'test'
}
}
- [Django]-How to keep empty lines in a textarea in Django admin UI?
- [Django]-Django 1.9.4 template inheritance does not work
1👍
I use almost the same solution for test, like @Simon Bächler, but instead of real database
'NAME': 'test',
I use
'NAME':' :memory:,
So it use memory to handle test operations, and thats why it doesn’t always create/update/delete the db.
👤Igor
- [Django]-Password field is visible and not encrypted in Django admin site
- [Django]-How to change tastypie time format
- [Django]-Django: How to restart webserver so that changes in sourcecode get applied
- [Django]-Superuser authenticate in class based view
- [Django]-Select a valid choice. That choice is not one of the available choices
Source:stackexchange.com