I am writing test for my Django app. I want to start Django with different settings value and run tests for each case. (eg one test for settings.ALLOW_ROBOTS=True and another test for settings.ALLOW_ROBOTS=False). I am not interested in overriding the value at run time. I want to start the server with different settings value each time. Does Django provide a way to accomplish this?
You can choose which settings.py file to use with
DJANGO_SETTINGS_MODULE; you can have many that import * from a main one, and then change what needs to be changed.
Alternatively, settings.py is just a Python file. You can get values of settings from environment variables, if you want:
import os ALLOW_ROBOTS = bool(os.getenv('ALLOW_ROBOTS', False))
And then change that environment variable from Travis.