0
votes

I am adding a pipeline step to run unit tests - the test suite is small and should execute quickly. However, the Run PyTest task is timing out. I set the timeout to 15 minutes which should be far more than enough time for the test suite to run (it takes 2.5 seconds for them to run in the IDE)

The logs show the last command being run is:

python.exe -m pytest --color=no -q --test-run-title="Unit Tests" --basetemp="D:\a\1\s" --junitprefix="py%winver%" --cov=test_module_A --cov=test_module_B --cov-report=xml --cov-report=html --pylint "D:\a\1\s\tests\test_module_A.py" "D:\a\1\s\tests\test_module_B.py"

The YAML for my Run PyTest task:

steps:
- task: stevedower.python.PyTest.PyTest@2
  displayName: 'Run PyTest'
  inputs:
    title: 'Unit Tests'
    testroot: tests
    patterns: 'test_*.py'
    resultfile: tests
    doctests: false
    pylint: true
    codecoverage: 'test_module_A, test_module_B'
  timeoutInMinutes: 15

It seems that the tests are not actually executing despite the pytest command being run. I am not aware of any additional logs that I should be looking at for more detailed test run information.

2
can you confirm same command works locally? for me pytest works just fine. I'm using a script step though4c74356b41
@4c thanks for the response. The command runs locally just fine. Not easy to track this down when I can't repro locally, let alone get any meaningful logging statement or error message :/ One thing that just occurred to me is that the projects (many) linting errors may be causing the task to hang rather than fail, but it seems unlikely. I suppose these need to be fixed anyway, so I'll try that and report back...futuregadgetlab

2 Answers

1
votes

My tests were (unbeknownst to me) attempting to log in to Azure, so the test run was hanging at the login prompt. Be sure to mock out Azure ML Workspace object, not just the GetWorkspace() calls

0
votes

In the corresponding pipeline job, enabling:

Allow scripts to access the OAuth token

Solved the issue for me.