title: How to mock/patch whole class?
body: <p>I have following code:</p>
  
  <pre><code>pkg1/mock_class.py:
  
  class A:
      def ma(self):
          print(' class_A')
  
  
  class B:
      def __init__(self):
          self.var = 'vvv'
  
      def mb(self):
          a = A()
          print('class_B')
          a.ma()
  </code></pre>
  
  <p>and test code:</p>
  
  <pre><code>from unittest import mock
  import pytest
  from pkg1.mock_class import B
  
  
  @pytest.fixture(scope='class')
  def mockA():
      with mock.patch('pkg1.mock_class.A'):
          yield
  
  class TestB:
      def test_b(self, mockA):
          b = B()
          b.mb()
  </code></pre>
  
  <p>I want to mock whole class A () using fixture and i would like to be able to configure some return values probably using parametrization in future.</p>
  
  <p>Basic - just mocking/patching as implemented above is not working class B is mocked and i don't understand why.</p>
  
  <p>Thanks for advice.</p>
  
  <p>Jano</p>