title: ModuleNotFoundError with pytest
body: <p>I want my <a href="https://docs.pytest.org/en/latest/goodpractices.html#tests-outside-application-code" rel="noreferrer">tests folder separate</a> to my application code. My project structure is like so</p>
  
  <pre><code>myproject/
    myproject/
      myproject.py
      moduleone.py
    tests/
      myproject_test.py
  </code></pre>
  
  <p>myproject.py</p>
  
  <pre><code>from moduleone import ModuleOne
  
  class MyProject(object)
  ....
  </code></pre>
  
  <p>myproject_test.py</p>
  
  <pre><code>from myproject.myproject import MyProject
  import pytest
  
  ...
  </code></pre>
  
  <p>I use <code>myproject.myproject</code> since I use the command</p>
  
  <pre><code>python -m pytest
  </code></pre>
  
  <p>from the project root directory <code>./myproject/</code></p>
  
  <p>However, then the imports within those modules fail with</p>
  
  <blockquote>
    <p>E   ModuleNotFoundError: No module named 'moduleone'</p>
  </blockquote>
  
  <p>I am running Python 3.7 and have read that since 3.3, empty <code>__init__</code> files are no longer needed which means my project becomes an <a href="https://stackoverflow.com/a/52812525/817379">implicit namespace package</a></p>
  
  <p>However, I have tried adding an <code>__init__.py</code> file in <code>myproject/myproject/</code> and also tried adding a <code>conftest.py</code> file in <code>myproject/</code> but  neither works</p>
  
  <p>I have <a href="https://stackoverflow.com/a/48694855/817379">read answers</a> that say to <a href="https://stackoverflow.com/a/49605901/817379">mess with the paths</a> and then upvoted comments in other questions saying <a href="https://stackoverflow.com/q/49723266/817379">not to</a>.</p>
  
  <p>What is the correct way and what am I missing?</p>
  
  <p><strong>EDIT;</strong></p>
  
  <p>Possibly related, I used a <code>requirements.txt</code> to install pytest using pip. Could this be related? And if so, what is the correct way to install pytest in this case?</p>
  
  <p><strong>EDIT 2:</strong></p>
  
  <p>One of the paths in <code>sys.path</code> is <code>/usr/src/app/</code> which is a docker volume lined to <code>/my/local/path/myproject/</code>.</p>
  
  <p>Should the volume be <code>/my/local/path/myproject/myproject/</code> instead?</p>