Relative/script imports in python test

Write instead

import sys
import os

this_dir= os.path.dirname(os.path.realpath(__file__))
sys.path.append(os.path.join(this_dir, "include"))

from logic_analyzer import LogicAnalyser  # type: ignore
from test_parser import TestParser  # type: ignore

See https://stackoverflow.com/questions/16114391/adding-directory-to-sys-path-pythonpath

1 Like