title: Running pytest with separate test files
body: <p>I have a directory structure as recommended by <a href="https://docs.pytest.org/en/latest/goodpractices.html" rel="nofollow noreferrer">the pytest good integration practices guide</a>, which looks like this:</p>
  
  <pre><code>.
  src/
      mypkg/
            __init__.py
            mypkg.py
  tests/
        __init__.py
        test_mypkg.py
  </code></pre>
  
  <p>The <code>__init__.py</code> files are both empty, and the other files are as follows:</p>
  
  <h2><code>mypkg.py</code></h2>
  
  <pre><code>def foo(x):
      """
      Show x.
      &gt;&gt;&gt; foo(5)
      x is 5
      &gt;&gt;&gt; foo("hello")
      x is hello
      """
      return "x is {0}".format(x)
  </code></pre>
  
  <h2><code>test.py</code></h2>
  
  <pre><code>from mypkg import *
  def test_foo():
      assert foo(5) == "x is 5"
  </code></pre>
  
  <p>When I run <code>pytest</code> from the root directory I get:</p>
  
  <pre><code>tests\test_foo.py:1: in &lt;module&gt;
      from mypkg import *
  E   ModuleNotFoundError: No module named 'mypkg'
  </code></pre>
  
  <p>What is the recommended way of setting this up?</p>