How to mock django settings attribute used in another module?
You can also use the following decorator on your individual test functions or test class as a whole. For example:
from django.test import override_settings
@override_settings(BASE_URL='http://localhost')
def test_case()
...
Try to use context manager settings() built-in django.
with self.settings(BASE_URL='http://localhost'):
# perform your test
https://docs.djangoproject.com/en/dev/topics/testing/tools/#django.test.SimpleTestCase.settings