title: How to import own module for mocking? (import error: no module named my_module!)
body: <p>I want to unit test my class, which is in another file named <code>client_blogger.py</code>.</p>
  
  <p>My unit test file, is in the same directory. All of my other unit tests work, except when I try to mock one of my own methods.</p>
  
  <pre><code>## unit_test_client_blogger.py
  import mock
  import json
  
  from client_blogger import BloggerClient, requests
  
  Class TestProperties():
  
      @pytest.fixture
  
      def blog(self):
      return BloggerClient(api_key='123', url='http://example.com')
  
      @mock.patch('client_blogger._jload')
      @mock.patch('client_blogger._send_request')
  
      def test_gets_blog_info(self, mock_send, mock_jload):
      """ Get valid blog info from API response. """
  
      valid_blog_info = 'some valid json api response here'
      parsed_response = json.loads(valid_blog_info)
      correct_blog_id = '7488272653173849119'
      mock_jload.return_value = valid_blog_info
  
      id = self.blog().get_blog_info(parsed_response)
      assert id == correct_blog_id
  </code></pre>
  
  <p>And here is the client_blogger.py file contents:</p>
  
  <pre><code># client_blogger.py
  import requests, json
  
  class BloggerClient(object):
      """ Client interface for Blogger API. """
      def __init__(self, key, url):
           # removed some code here for brevity
  
      def _send_request(self, api_request):
          """ Sends an HTTP get request to Blogger API.
              Returns HTTP response in text format. """
          # snip
  
      def _jload(self, api_response):
          """ Accepts text API response. Returns JSON encoded response. """
          # snip
  
      def get_blog_info(self):
          """ Makes an API request. Returns Blog item information. """
          request = '{b}/blogs/byurl?url={u}&amp;key={k}'.format(b=self.base, u=self.url, k=self.key)
          txt_response = self.send_request(request)
          response = self._jload(txt_response)
          return response['id']
  </code></pre>
  
  <p>I want to mock out <code>self.send_request()</code> and <code>self._jload()</code> method calls in the above method. </p>
  
  <p>But Mock module complains: <code>ImportError: No module named client_blogger</code>.</p>
  
  <p>The error must lie here:</p>
  
  <pre><code>@mock.patch('client_blogger._jload')
  @mock.patch('client_blogger._send_request')
  </code></pre>
  
  <p>I've tried many variations in order to get mock.patch to find my module or class. But none of them have worked.</p>
  
  <p>I've tried the following:</p>
  
  <pre><code>@mock.patch('client_blogger.BloggerClient._jload')
  @mock.patch('BloggerClient._jload')
  @mock.patch('._jload')
  </code></pre>
  
  <p>None of those work. Any idea how to mock.patch a method from my own module?</p>
  
  <p>(It seems strange, because I can mock.patch other modules, just not my own :-s)</p>