I also did not want to redefine all the text, so I copied the corresponding dictionary from the settings object and simply changed the attribute that interests me:
import copy from django.conf import settings settings_dict = deepcopy(settings.SETTINGS_DICT) settings_dict['key1']['key2'] = 'new value' @override_settings(SETTINGS_DICT=settings_dict) def test_something(self): pass
This is suitable for my purposes, but if you want to make it more widely used, you can write a short function with several arguments that can do something like this dynamically.
Note: I tried using settings.SETTINGS_DICT.copy() instead of deepcopy(settings.SETTINGS_DICT) but it seems to override the setting globally for all tests ...
source share