title: ImportError shows up with py.test, but not when running the app
body: <p>Unlike in this question:
  <a href="https://stackoverflow.com/questions/37469473/importing-modules-from-a-sibling-directory-for-use-with-py-test">Importing modules from a sibling directory for use with py.test</a>
  I can import something from my app, but there's an import error (looking like a circular dependency) that raises from <em>'inside'</em> <code>myapp</code> while running the test and not when running <code>myapp</code> alone:</p>
  
  <pre><code>$ python3 myapp/myapp.py
  Some dummy string (correct output)
  </code></pre>
  
  <p>But:</p>
  
  <pre><code>$ python3 -m pytest                                                                               
  ================================================================= test session starts =================================================================
  platform linux -- Python 3.4.3, pytest-2.9.1, py-1.4.31, pluggy-0.3.1
  rootdir: /home/nico/temp/projects_structures/test04/myapp, inifile: 
  plugins: cov-2.2.1
  collected 0 items / 1 errors 
  
  ======================================================================= ERRORS ========================================================================
  ________________________________________________________ ERROR collecting tests/test_things.py ________________________________________________________
  tests/test_things.py:4: in &lt;module&gt;
      from myapp.lib.core.base import do_things
  myapp/lib/core/base.py:1: in &lt;module&gt;
      from lib import something
  E   ImportError: No module named 'lib'
  =============================================================== 1 error in 0.05 seconds ===============================================================
  </code></pre>
  
  <p>As you can see, the problem is <em>not</em> the <code>import</code> statement from the test file. It's raised from 'inside' <code>myapp</code>.</p>
  
  <p>Here is the complete structure:</p>
  
  <pre><code>.
  └── myapp
      ├── myapp
      │   ├── __init__.py
      │   ├── lib
      │   │   ├── core
      │   │   │   ├── base.py
      │   │   │   └── __init__.py
      │   │   └── __init__.py
      │   └── myapp.py
      └── tests
          └── test_things.py
  </code></pre>
  
  <p>myapp.py contains:</p>
  
  <pre><code>#!/usr/bin/env python3
  
  from lib.core import base
  
  base.do_things()
  </code></pre>
  
  <p>lib/__init__.py contains:</p>
  
  <pre><code>something = "Some dummy string (correct output)"
  </code></pre>
  
  <p>base.py contains:</p>
  
  <pre><code>from lib import something
  
  def do_things():
      print(something)
      return True
  </code></pre>
  
  <p>and test_things contains:</p>
  
  <pre><code>import unittest
  import sys
  sys.path.insert(0, '..')
  from myapp.lib.core.base import do_things
  
  class DoThingsTestCase(unittest.TestCase):
  
      def test_do_things(self):
          self.assertTrue(do_things())
  
  if __name__ == '__main__':
      unittest.main()
  </code></pre>
  
  <p>And <code>$PYTHONPATH</code> seems correctly set (so this: 
  <a href="https://stackoverflow.com/questions/20985157/py-test-no-module-named">Py.test No module named *</a>
  doesn't answer my problem). (Or if this is not correct, how can I correct it?)</p>
  
  <pre><code>$ echo $PYTHONPATH
  /home/nico/temp/projects_structures/test04/myapp/myapp
  </code></pre>