title: How to overwrite django app settings in unittests?
body: <p>Django allows overwriting settings, when running tests through <code>SimpleTestCase.settings()</code> (<a href="https://docs.djangoproject.com/en/1.8/topics/testing/tools/#django.test.SimpleTestCase.settings" rel="nofollow noreferrer">https://docs.djangoproject.com/en/1.8/topics/testing/tools/#django.test.SimpleTestCase.settings</a>). That works fine when I try to overwrite one of Django's settings.</p>
  
  <p>The app I want to run tests for carries its own settings in an app-specific <code>settings.py</code> with the following structure to allow overwriting the app-specific settings in the project wide <code>settings.py</code>:</p>
  
  
  
  <pre><code>from django.conf import settings
  APP_SETTING1 = getattr(settings, 'APP_SETTING1', 'foo')
  </code></pre>
  
  <p>The following dummy code in a test shows the problem:</p>
  
  
  
  <pre><code>from django.test import TestCase
  from django.conf import settings as django_settings
  from my_app import settings
  
  class MyTestCase(TestCase):
      def test_something(self):
          with self.settings(APP_SETTING1='bar'):
              print(django_settings.APP_SETTING1)    # bar
              print(settings.APP_SETTING1)           # foo
  </code></pre>
  
  <p>Why isn't that working and how can I make it work?</p>