title: pytest 'No module named ...' for import within the tested module
body: <p>I found some questions that are similar but did not quite solve my problem (e.g. <a href="https://stackoverflow.com/questions/10253826/path-issue-with-pytest-importerror-no-module-named-yadayadayada?rq=1">PATH issue with pytest 'ImportError: No module named YadaYadaYada'</a>)</p>
  
  <p>My project is structured as follows:</p>
  
  <pre><code>MyApp
   |
   +--MyApp
   |   |
   |   +--__init__.py
   |   +--app.py
   |   +--config.py
   |
   +--tests
       |
       +--__init__.py
       +--test_app.py
  </code></pre>
  
  <p>in my test_app.py I import app.py, which works just fine.</p>
  
  <p><code>from MyApp import app</code></p>
  
  <p>but within app.py I import config.py like this.</p>
  
  <p><code>import config</code></p>
  
  <p>With this setup I can run the app module, but pytest fails to import 'config' and raises:</p>
  
  <p><code>ImportError: No module named 'config'</code></p>
  
  <p>pytest succeeds when I change the import statement in app.py to:</p>
  
  <p><code>from MyApp import config</code></p>
  
  <p>However, an error is raised when I try to run the app:</p>
  
  <p><code>ImportError: No module named 'MyApp'</code></p>
  
  <p>From reading other questions I'm confident that there is something wrong with the <code>PYTHONPATH</code>, I just could not figure out how to fix this.</p>