title: Why don't my Django unittests know that MessageMiddleware is installed?
body: <p>I'm working on a Django project and am writing unittests for it. However, in a test, when I try and log a user in, I get this error:</p>
  
  <pre><code>MessageFailure: You cannot add messages without installing django.contrib.messages.middleware.MessageMiddleware
  </code></pre>
  
  <p>Logging in on the actual site works fine -- and a login message is displayed using the MessageMiddleware.</p>
  
  <p>In my tests, if I do this:</p>
  
  <pre><code>from django.conf import settings
  print settings.MIDDLEWARE_CLASSES
  </code></pre>
  
  <p>Then it outputs this:</p>
  
  <pre><code>('django.middleware.cache.UpdateCacheMiddleware',
  'django.middleware.common.CommonMiddleware',
  'django.contrib.sessions.middleware.SessionMiddleware',
  'django.middleware.csrf.CsrfViewMiddleware',
  'django.contrib.auth.middleware.AuthenticationMiddleware',
  'django.contrib.messages.middleware.MessageMiddleware',
  'django.middleware.clickjacking.XFrameOptionsMiddleware',
  'django.middleware.cache.FetchFromCacheMiddleware',
  'debug_toolbar.middleware.DebugToolbarMiddleware')
  </code></pre>
  
  <p>Which appears to show the MessageMiddleware is installed when tests are run.</p>
  
  <p>Is there an obvious step I'm missing?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>After suggestions below, it does look like it's a settings thing.</p>
  
  <p>I currently have <code>settings/__init__.py</code> like this:</p>
  
  <pre><code>try:
      from settings.development import *
  except ImportError:
      pass
  </code></pre>
  
  <p>and <code>settings/defaults.py</code> containing most of the standard settings (including <code>MIDDLEWARE_CLASSES</code>). And then <code>settings.development.py</code> overrides some of those defaults like this:</p>
  
  <pre><code>from defaults import *
  
  DEBUG = True
  # etc
  </code></pre>
  
  <p>It looks like my dev site itself works fine, using the development settings. But although the tests seem to load the settings OK (both defaults and development) <code>settings.DEBUG</code> is set to <code>False</code>. I don't know why, or whether that's the cause of the problem. </p>