I'm trying to run a python test in Azure DevOps and the only error I'm receiving is this:
==================================== ERRORS ====================================
_________________ ERROR collecting tests/unit/test_handler.py __________________
ImportError while importing test module '/home/vsts/work/1/s/tests/unit/test_handler.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/importlib/__init__.py:127: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
tests/unit/test_handler.py:5: in <module>
from hello_world import app
E ModuleNotFoundError: No module named 'hello_world'
----------- generated xml file: /home/vsts/work/1/s/test-output.xml ------------
I'm really not sure why it's saying "No module named 'hello_world'"? Here is my YAML configuration for my pipeline, is this the issue?
trigger:
- main
pool:
vmImage: ubuntu-latest
strategy:
matrix:
Python37:
python.version: '3.7'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(python.version)'
displayName: 'Use Python $(python.version)'
- script: |
python -m pip install --upgrade pip
pip install -r hello_world/requirements.txt
displayName: 'Install dependencies'
- script: |
pip install pytest pytest-azurepipelines
pytest
displayName: 'pytest'