title: How to import a python package in pytest using relative import
body: <pre><code>my-proj
  ├── src
  │   ├── main.py
  └── test
  │   ├── my_tests.py
  </code></pre>
  <p>I have the above directory structure for my python project. I have some unittests in the my_test.py and when I run them, I get the following error using following imports:</p>
  <pre><code>import os, sys
  import json
  from ..src import main
  import unittest
  </code></pre>
  <p>running like this from my-proj/test/ directory: <strong>python my_tests.py</strong></p>
  <blockquote>
  <p>from ..src import main</p>
  <p>ValueError: attempted relative import beyond top-level package</p>
  </blockquote>
  <p>Apologies if this was answered but i tried a few things, even included __ main __.py in both directories (src and test) but didn't work. Any idea how I can get this to work?
  It is a FLASK application in python (main.py)</p>