title: Mock nested method in Python
body: <p>Wracking my brain on this. I want to mock generator methods <code>self.api.redditor(username).comments.new(limit=num)</code> and <code>self.api.redditor(username).submissions.new(limit=num)</code> below, in which <code>self.api</code> is assigned to a class instance, as in <code>self.api = PrawReddit()</code></p>
  
  <p>I'm trying to test the size of the result: <code>self.assertEqual(len(result), 5)</code></p>
  
  <p>So far, I tried <code>MockPraw.return_value.redditor.return_value.comments.return_value.new.return_value.__iter__.return_value = iter(['c' * 10])</code> but the test fails with <code>AssertionError: 0 != 5</code></p>
  
  <p>Any tips much appreciated.</p>
  
  <pre><code>def get_comments_submissions(self, username, num=5):
      """Return max `num` of comments and submissions by `username`."""
      coms = [
          dict(
              title=comment.link_title,
              text=comment.body_html,
              subreddit=comment.subreddit_name_prefixed,
              url=comment.link_url,
              created=datetime.fromtimestamp(comment.created_utc, pytz.utc),
          )
          for comment in self.api.redditor(username).comments.new(limit=num)
      ]
      subs = [
          dict(
              title=submission.title,
              text=submission.selftext_html,
              subreddit=submission.subreddit_name_prefixed,
              url=submission.url,
              created=datetime.fromtimestamp(submission.created_utc, pytz.utc),
          )
          for submission in self.api.redditor(username).submissions.new(limit=num)
      ]
      return coms + subs if len(coms + subs) &lt; num else (coms + subs)[:num]
  </code></pre>