title: nosetests framework: how to pass environment variables to my tests?
body: <p>I have a test suite that gets executed as a part of a larger build framework, written in Python. Some of the tests require parameters, which I want to pass using environment variables.</p>
  
  <p>Apparently the nosetests runner has an <code>env</code> parameter, which does what I want, <a href="http://nose.readthedocs.org/en/latest/api/core.html#nose.core.run" rel="noreferrer">according to the documentation.</a> It seems, however, that it does not work as thought it should?</p>
  
  <p>Here's a minimal test script that exemplifies the problem:</p>
  
  <pre><code>#!/usr/bin/env python
  # pip install nose
  
  import os, nose, unittest
  
  class Test(unittest.TestCase):
      def test_env(self):
          self.assertEquals(os.environ.get('HELLO'), 'WORLD')
  
  if __name__ == '__main__':
      nose.run(env={'HELLO': 'WORLD'})
  </code></pre>
  
  <p>The assertion fails, because the <code>env</code> parameter does not get passed to the test. Does anyone know why?</p>
  
  <p>NB: I worked around the problem by launching the console <code>nosetests</code> tool:</p>
  
  <pre><code>#!/usr/bin/env python
  
  import sys, os, nose, unittest, subprocess
  
  class Test(unittest.TestCase):
      def test_env(self):
          self.assertEquals(os.environ.get('HELLO'), 'WORLD')
  
  if __name__ == '__main__':
      subprocess.Popen(['nosetests', sys.argv[0]],
                       env={'HELLO': 'WORLD'}).wait()
  </code></pre>
  
  <p>However, this feels like a kludge, and I'd still be interested in learning to use <code>nose.run()</code> properly.</p>