title: django setting environment variables in unittest tests
body: <p>I want to be able to set environment variables in my Django app for tests to be able to run. For instance, my views rely on several API keys.</p>
  
  <p>There are ways to <a href="https://docs.djangoproject.com/en/1.8/topics/testing/tools/#overriding-settings" rel="noreferrer">override settings during testing</a>, but I don't want them defined in <code>settings.py</code> as that is a security issue. </p>
  
  <p>I've tried in my setup function to set these environment variables, but that doesn't work to give the Django application the values.</p>
  
  <pre><code>class MyTests(TestCase):
      def setUp(self):
          os.environ['TEST'] = '123'  # doesn't propogate to app
  </code></pre>
  
  <p>When I test locally, I simply have an <code>.env</code> file I run with </p>
  
  <pre><code>foreman start -e .env web
  </code></pre>
  
  <p>which supplies <code>os.environ</code> with values. But in Django's <code>unittest.TestCase</code> it does not have a way (that I know) to set that. </p>
  
  <p>How can I get around this?</p>