title: How to mock a method that is not in the scope of a test?
body: <h3>How to mock a method that is not in the scope of a test?</h3>
  <p><strong>or:</strong> How to mock a method that is not called directly?</p>
  <p>In this case method <strong>baz</strong><br />
  I'm using the <a href="https://pypi.python.org/pypi/mock" rel="nofollow noreferrer">Mock package</a> from pypi</p>
  <pre><code>### tests
  # ...
  def test_method_a(self):
      # how to mock method that is called from bar() ?
      obj = foo.bar()
      self.assertEqual(obj.get('x'), 12345)
  
  ### foo
  # ...
  def bar():
      x = some_module.baz()  # &lt;- how to mock baz() ?
      return x
  </code></pre>