I'm writing a python test script and have a directory structure like the following:
user ---- dir1
| |---- dir2
| |--- dir-3
|--- temp |------dut.py
|
|---test_script.py
- Notice the
-indir-3
I need to import dut.py into test_script.py so that I can instance the class and test features. Ideally, these two scripts would be in the same directory as I have done in previous tests but for this, they need to stay where they are. I cannot seem to be able to import dut.py though. I've searched online and other posts here and tried the following:
I have tried:
from user.dir1.dir2.dir-3 import dut
In this method, it complains about the - in the directory names
I have also tried:
import sys
sys.path.insert(0, "user/dir1/dir2/dir-3/")
import dut
In this method, it says it cannot find the module named dut
How can I import this file into my test script so I can use an instance of the class?