title: Why can't I patch multiprocessing.Process?
body: <p>So I have these files:</p>
  <p><strong>transmitter.py</strong></p>
  <pre class="lang-py prettyprint-override"><code>import multiprocessing as MP
  from common import BaseWorker
  
  class TxWorker(BaseWorker):
      ... code ...
  </code></pre>
  <p><strong>common.py</strong></p>
  <pre class="lang-py prettyprint-override"><code>import multiprocessing as MP
  
  class BaseWorker(MP.Process):
      ... code ...
  </code></pre>
  <p>Now I have this test file, written for pytest with pytest-mock plugin:</p>
  <pre class="lang-py prettyprint-override"><code>from transmitter import TxWorker
  
  class MockProcess:
      def __init__(self, name, *args, **kwargs):
          self.name = name
  
      def canary():
          return &quot;Mocked!&quot;
  
  @pytest.fixture(scope=&quot;module&quot;)
  def mocked_process(module_mocker):
      module_mocker.patch(WHERE_TO_PATCH, MockProcess)
      yield
  
  def test_case(mocked_process):
      tw = TxWorker()
      assert tw.canary() == &quot;Mocked!&quot;
  </code></pre>
  <p>I can't get this test to work.</p>
  <p>I've tried setting <code>WHERE_TO_PATCH</code> to:</p>
  <ul>
  <li><code>transmitter.MP.Process</code></li>
  <li><code>common.MP.Process</code></li>
  <li><code>multiprocessing.Process</code></li>
  </ul>
  <p>None of them works. I keep having the error <code>AttributeError: 'TxWorker' object has no attribute 'canary'</code>.</p>
  <p>Where did I go wrong?</p>