title: How to mock os.environ using py.test monkeypatch
body: <p>I'm trying to mock <code>os.environ</code> but I get this error.</p>
  
  <pre><code>       monkeypatch.setattr(os, 'environ', mock_env)
  E       TypeError: unbound method setattr() must be called with monkeypatch instance as first argument (got module instance instead)
  </code></pre>
  
  <p>Here's my code.</p>
  
  <pre><code> def test_feed(self):
          self.upload_file()
          def mock_env():
              return get_config()
  
          monkeypatch.setattr(os, 'environ', mock_env)
  
          response = self.app.get('/feed')
  
          self.assertEquals('&lt;xml&gt;&lt;/xml&gt;', response.data)
  </code></pre>
  
  <p>And here's the method I'm testing using Flask</p>
  
  <pre><code>@app.route("/feed")
  def feed(env=os.environ):
      mrss_feed = FeedBurner(env=env).get_feed()
      response = make_response(mrss_feed)
      response.headers["Content-Type"] = "application/xml"
  
      return response
  </code></pre>