title: Pytest: how to work around missing __init__.py in the tests folder?
body: <p>I am storing all the pytest files in the <code>tests</code> sub-directory under the project root. There is no <code>__init__.py</code> in that directory or above and <code>pytest tests/test_a.py</code> works as expected. I can also run <code>pytest test_a.py</code> directly from within the <code>tests</code> folder.</p>
  
  <pre><code>|--&lt;project_root&gt;
  +---[tests]
      test_a.py
      base.py
      config.py
      conftest.py
  </code></pre>
  
  <p>The test class in <code>test_a.py</code> inherits from <code>base.py</code>. Now, the problem is that because of the missing <code>__init__.py</code> the IDE tooling does not work and the imports cannot be resolved. Adding <code>__init__.py</code> under the <code>tests</code> resolves all import errors in the IDE, but tests won't run anymore with <code>pytest test_a.py</code> because py.test fails to import <code>conftest.py</code>.</p>
  
  <p>In my <code>conftest.py</code> I have the following imports:</p>
  
  <pre><code>from config import HOST_URL_DEFAULT, USER, PASSWORD
  </code></pre>
  
  <p>which results in:</p>
  
  <pre><code>ModuleNotFoundError: No module named 'config'
  ERROR: could not load /project_root/tests/conftest.py
  </code></pre>
  
  <p>Is there a way to solve this so that both IDE tooling works <em>and</em> <code>pytest</code> keeps working? I would like to avoid using dot imports, if possible.</p>
  
  <p><sup><em>Update:</em> After reading <a href="https://stackoverflow.com/a/14132912/191246">this answer</a> I think I am finally starting to understand a bit more how python imports work.</sup></p>