Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
610 views
in Technique[技术] by (71.8m points)

Azure Devops pipeline pytest collection failure ModuleNotFoundError: No module named

I get the following error when running an azure pipeline. enter image description here

Here is the pytest part of my pipelines yaml file.

 steps:
  #test
  - task: UsePythonVersion@0
    inputs:
      versionSpec: '$(python.version)'
    displayName: 'Use Python $(python.version)'

  #test
  - script: |
      python -m pip install --upgrade pip
      python -m pip install wheel
      pip install -r requirements.txt
    condition: ne(variables.CACHE_RESTORED, 'true')
    displayName: 'Install dependencies'
  #test
  - script: |
      python -m spacy download de_core_news_sm
      python -m spacy download de_core_news_md
  #test
  - script: |
      pip install pytest pytest-azurepipelines
      pytest
    displayName: 'pytest'

The file tat_core/criteria/checks/zw2n_test.py does not exist on my local copy of the repository. I deleted it.

How can I tell the pipeline that the file does not exist and the test does not have to be run? I assume there is some kind of caching indicated by the path /opt/hostedtoolscache. Can I empty this cache?

question from:https://stackoverflow.com/questions/65950931/azure-devops-pipeline-pytest-collection-failure-modulenotfounderror-no-module-n

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can try to remove the '__init__.py' file form your project to see if it can work, like as mentioned in this topic.

In addition, please also try the pytest for the same project on your local machine to see if the same issue occurs.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...