title: unittesting: patching an objects __base__
body: <p>Following on from <a href="https://stackoverflow.com/questions/20539769/python-unittesting-super-calls">this question</a>, I attempted to patch class <code>A()</code> with <code>Mock()</code> so that when <code>B()</code> was initialised, the Mock was used as a base e.g.:</p>
  
  <pre><code>class A(object): ...
  class B(A): ...
  
  def setUp(self):
      with patch('A', new_callable=Mock) as MockObject:
          self.b = B()
          self.b.__class__.__base__ = MockOjbect
  </code></pre>
  
  <p>Which doesn't work because <strong>base</strong> is read only. What's the correct way to go about doing this?</p>
  
  <p>update:</p>
  
  <pre><code>&gt;&gt;&gt; from mock import Mock
  &gt;&gt;&gt; class A(object):
  ...     pass
  ... 
  &gt;&gt;&gt; class B(A):
  ...     pass
  ... 
  &gt;&gt;&gt; b.__class__.__bases__ = (Mock, )
  &gt;&gt;&gt; b.__class__.__bases__
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    File "/opt/envs/myenv/local/lib/python2.7/site-packages/mock.py", line 656, in __getattr__
      elif self._mock_methods is not None:
    File "/opt/envs/myenv/local/lib/python2.7/site-packages/mock.py", line 655, in __getattr__
      raise AttributeError(name)
  AttributeError: _mock_methods
  </code></pre>
  
  <p>To be clear, I'm not convinced this is the best way to achieve what I want to do, I'm half hoping someone else will come up with another way.</p>