title: Mocking confused with __init__.py module
body: <p>I'm currently trying to use mock to test a package. Mock seems to not like it when I structure my python modules in different directories using <code>__init__.py</code></p>
  
  <p>My file tree is as follows:</p>
  
  <pre><code>.\pkg
    |_ module
         |_ __init__.py
         |_ module.py
    |_ tests
         |_ __init__.py
         |_ test_basic.py
  </code></pre>
  
  <p>When I try to mock the methods inside filesize using the following unit test:</p>
  
  <pre><code>@mock.patch('module.os')
  def test_filesize(self, mock_os):
      class file_info:
          st_size = 1000
  
      mock_os.path.isfile.return_value = True
      mock_os.stat.return_value = file_info
  
      output = self.response.file_size("filename")
  </code></pre>
  
  <p>I get an error with a traceback of:</p>
  
  <pre><code>======================================================================
  ERROR: test_filesize (__main__.cl_test_build_search_url)
  ----------------------------------------------------------------------
  Traceback (most recent call last):
    File "C:\Python36\lib\site-packages\mock\mock.py", line 1297, in patched
      arg = patching.__enter__()
    File "C:\Python36\lib\site-packages\mock\mock.py", line 1369, in __enter__
      original, local = self.get_original()
    File "C:\Python36\lib\site-packages\mock\mock.py", line 1343, in get_original
      "%s does not have the attribute %r" % (target, name)
  AttributeError: &lt;module 'module' from 'C:\\Users\\username\\work\\open_source\\pkg\\module\\__init__.py'&gt; does not have the attribute 'os'
  </code></pre>
  
  <p>I have imported the os module in <code>module.py</code> but I think it's getting confused because the <code>__init__.py</code> is confusing the interpreter?</p>
  
  <p>I've looked at the mock.patch arguments available and </p>
  
  <p><code>@mock.patch('module.os', create = True)</code></p>
  
  <p>allowed the code to run but os doesn't end up being mocked at all and <code>os.path.isfile</code> and <code>os.stat</code> doesn't get overridden during run time.</p>