title: How to mock.patch a plain dictionary in python?
body: <p>How do I mock.patch a plain dictionary {} ?</p>
  
  <p>I would like to check if the  headers is set to {'Content-Type': 'application/json’}.</p>
  
  <pre><code>def get(self):
      result = Spider.get_news_urls()
      for k, v in result.iteritems():
          response = requests.get(v)
          xml = response.text()
          headers = {'Content-Type': 'application/json'}
          data = ''
          taskqueue.Task(url='/v1/worker', headers=headers, payload=json.dumps(data)).add(queue_name='itagnewstasks')
      return 'success', 200
  </code></pre>
  
  <p>The following unit test seems to successfully patch dict. But I have a {}, which I need to patch.</p>
  
  <pre><code>@mock.patch('__builtin__.dict')
  @mock.patch('requests.get')
  def test_header_is_set_to_json(self, req_get, x):
      gen = Generator()
      gen.get()
      x.assert_called_with()
  </code></pre>
  
  <p>I suppose an alternative way would be to mock patch <code>taskqueue.Task()</code> and compare if it was called with <code>headers= {'Content-Type': 'application/json'}</code> as a parameter.</p>