This is a nodejs and python project so the directory structure is the way it is.
This is my directory structure:
top_level/
scripts/
__init__.py
python_script.py
some_nodejs_files.js
tests/
__init__.py
test_python_script.py
I can put all my unit test code in the inside the scripts
directory but I would like to put test code in the test directory which is at the same level as scripts
. How do I import python_scripts.py
from test_python_script.py
From tests/test_python_script.py
I've tried doing a from ..scripts import python_script
but I get a ValueError: attempted relative import beyond top-level package
.
EDIT: After reading some of the links in the comments and trying some stuff out I added
import sys
sys.path.append("..")
from scripts import python_script
and that seems to do the trick.
What I learned
Where ever you have the init.py that folder is the name of the module.