title: Partially mock a method in unittest `setUp`
body: <p>I am trying to understand the mock/patch framework, but have a problem. Here are my simplified codes:</p>
  
  <pre><code>file_a.py
  class A:
    def f(self): 
      b = B()
      b.g()
      b.h()
  
  file_b.py
  class B:
    def g(self):
      return network_requests(...)
  
    def h(self):
      return "This is should not be mocked."
  
  file_test.py
  class SomeTests:
    def setUp(self):
      with patch('file_b.B', autospec=True) as mock:
        mock.g.return_value = "Mocked value"
        mock.side_effect = lambda : B()
      self.a = A()
  
    def test(self):
      self.a.f()
  </code></pre>
  
  <p>Essentially I want to mock only <code>B.g</code> inside the test, but not <code>B.h</code>. I got some idea from <a href="https://docs.python.org/3/library/unittest.mock-examples.html#partial-mocking" rel="nofollow">https://docs.python.org/3/library/unittest.mock-examples.html#partial-mocking</a>, but <code>B.g</code> is still not mocked. </p>
  
  <p>Thank you!</p>