Azure-pipelines: Нет модуля с именем "xmlrunner"
В Stackoverflow, похоже, много вопросов "No module names..." on Azure Pipelines... и теперь, поскольку никто из них мне не помог, настала моя очередь :(
)Вот конвейер, который я пытаюсь запустить: простой CI для тестирования моего приложения Django, основанный на собственном шаблоне Microsoft:
trigger:
- master
pool:
vmImage: ubuntu-latest
strategy:
matrix:
Python310:
PYTHON_VERSION: '3.10'
maxParallel: 2
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(PYTHON_VERSION)'
architecture: 'x64'
- task: DownloadSecureFile@1
name: dotEnv
inputs:
secureFile: 'uploaded.env'
- task: PythonScript@0
displayName: 'Export project path'
inputs:
scriptSource: 'inline'
script: |
"""Search all subdirectories for `manage.py`."""
from glob import iglob
from os import path
# Python >= 3.5
manage_py = next(iglob(path.join('**', 'manage.py'), recursive=True), None)
if not manage_py:
raise SystemExit('Could not find a Django project')
project_location = path.dirname(path.abspath(manage_py))
print('Found Django project in', project_location)
print('##vso[task.setvariable variable=projectRoot]{}'.format(project_location))
- task: CopyFiles@2
displayName: 'Add .env file'
inputs:
SourceFolder: '$(Agent.TempDirectory)'
Contents: 'uploaded.env'
TargetFolder: '$(projectRoot)'
- script: mv uploaded.env .env
displayName: 'Rename .env file'
- script: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install poetry
python -m pip install unittest-xml-reporting xmlrunner
poetry install
displayName: 'Install dependencies'
- script: |
pushd '$(projectRoot)'
poetry run python manage.py test --testrunner xmlrunner.extra.djangotestrunner.XMLTestRunner --no-input
poetry run coverage xml
displayName: 'Run tests'
- task: PublishTestResults@2
inputs:
testResultsFiles: "**/TEST-*.xml"
testRunTitle: 'Python $(PYTHON_VERSION)'
condition: succeededOrFailed()
- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: 'coverage.xml'
reportDirectory: 'htmlcov'
displayName: 'Publish Coverage Results'
На этапе тестирования это не удается, с ошибкой: ModuleNotFoundError: No module named 'xmlrunner'
Самое странное для меня то, что я вижу, что xmlrunner устанавливается в предыдущих шагах:
Кто-нибудь уже проходил через это?
Вы устанавливаете с помощью pip и xmlrunner, и unittest-xml-reporting, но вам, вероятно, нужна только unittest-xml-reporting. xmlrunner - это еще одна библиотека PyPi.
