title: Mock attributes in Python mock?
body: <p>I'm having a fairly difficult time using <code>mock</code> in Python:</p>
  
  <pre><code>def method_under_test():
      r = requests.post("http://localhost/post")
  
      print r.ok # prints "&lt;MagicMock name='post().ok' id='11111111'&gt;"
  
      if r.ok:
         return StartResult()
      else:
         raise Exception()
  
  class MethodUnderTestTest(TestCase):
  
      def test_method_under_test(self):
          with patch('requests.post') as patched_post:
              patched_post.return_value.ok = True
  
              result = method_under_test()
  
              self.assertEqual(type(result), StartResult,
                  "Failed to return a StartResult.")
  </code></pre>
  
  <p>The test actually returns the right value, but <code>r.ok</code> is a Mock object, not <code>True</code>. How do you mock attributes in Python's <code>mock</code> library?</p>