I'm trying to run some tests for my python application but I'm not able to set the path correctly so that my test.py
can find it.
My Application is structured like this:
repo/src/main/python/main_module
repo/tests/test.py
And my test.py
is looking like this:
import sys
sys.path.append(os.path.normpath('C:/repo/src/main/python'))
import main_module
Now I want to test the code within Azure Pipelines, so first I copy the repo in place:
- powershell: |
cd C:/
mkdir repo
cp -r -v $(src.repo)/* C:/repo/
condition: eq( variables['Agent.OS'], 'Windows_NT' )
After that I use tree
to test if everything was copied correctly.
And then I simply run the test script by calling:
python C:/repo/tests/test.py
But that gives me a ModuleNotFoundError
.
I've also tried setting the path to my main_module
via PYTHONPATH but that's not working too.
Is their something I missed or is this a bug within Azure Pipelines?
After talking to the Azure DevOps Support, I now know that my issue is a bug within DevOps-Pipelines at the moment.
For now I'm going to copy my test-scripts next to my main module and delete them if everything was successful and before building the application.