title: Mocking a class during import with Pytest
body: <p>How do I correctly mock out a class during import using pytest?
  For example:</p>
  
  <pre><code>#main_module.py
  
      from james import John
  
      class Fish:
        def run():
          return John()
  
  
  #test_main_module.py
      @patch('path/to/main_module/where/John/was/used')
      def test_main_module_uses_mork(mocker):
        MockJohn = mocker.Mock()
        assert type(Fish().run()) == MockJohn
  </code></pre>