title: django testing with local settings
body: <p>Python 2.7
  Django 1.2</p>
  
  <p>I am getting odd local_settings behavior when I am testing a Django app.  I have my <code>&lt;project&gt;/settings.py</code> set up like this:</p>
  
  <pre><code>DEBUG = False
  TEMPLATE_DEBUG = DEBUG
  
  ADMINS = (
          ("Me", "me@me.com"),
  )
  
  MANAGERS = ADMINS + (('Person1', 'person1@blah.com'),)
  
  # ... rest of settings
  
  try:
      from local_settings import *
  except ImportError:
      pass
  </code></pre>
  
  <p>and in <code>&lt;project&gt;/local_settings.py</code> I have:</p>
  
  <pre><code>DEBUG = True
  
  MANAGERS = (
          ('Me', 'me@me.com'),
  )
  </code></pre>
  
  <p>So, while working locally, the <code>MANAGERS</code> setting should be <code>(('Me', 'me@me.com'),)</code>, and <code>DEBUG</code> should be set to <code>True</code>.</p>
  
  <p>However, in the tests for one of my apps, I am testing <code>settings.DEBUG</code> and getting <code>False</code>, but the <code>MANAGERS</code> setting is set correctly (it just has 'Me' in it).  Any ideas why this would happen?  Here are the relevant parts of the <code>&lt;project&gt;/&lt;app&gt;/tests.py</code> file:</p>
  
  <pre><code>from django.conf import settings
  from django.test import TestCase
  
  # ...
  class MyTests(TestCase):
      def mytest(self):
          if settings.DEBUG:
              self.assertEqual(settings.MANAGERS, (('Me', 'me@me.com'),))
          else:
              self.assertEqual(settings.MANAGERS, (('Me', 'me@me.com'), ('Person1', 'person1@blah.com')))
  </code></pre>
  
  <p>The result is</p>
  
  <pre><code>AssertionError: (('Me', 'me@me.com'),) != (('Me', 'me@me.com'), ('Person1', 'person1@blah.com'))
  </code></pre>
  
  <p>So it looks like it is testing the <code>else</code> branch due to <code>settings.DEBUG</code> being set incorrectly, and then raising <code>AssertionError</code> since <code>settings.MANAGERS</code> is set correctly.</p>
  
  <p>If I run <code>python manage.py shell</code> I get this:</p>
  
  <pre><code>&gt;&gt;&gt; from django.conf import settings
  &gt;&gt;&gt; settings.DEBUG
  True
  &gt;&gt;&gt; settings.MANAGERS
  (('Me', 'me@me.com'),)
  </code></pre>
  
  <p>So they are set correctly there.</p>
  
  <p>I know I can override settings manually in my tests, but I wanted to try to use <code>settings.DEBUG</code> so that the test would pass no matter whether it was being run locally or in production.</p>
  
  <p>Any ideas?</p>