Reputation: 3703
I have a python application that has pytest unit tests running as part of a build on Azure DevOps. The tests have started failing this morning without any changes to the code.
Here's a minimal reproducible example. I have a file called test_a.py
with the following contents:
def test_assert_true():
assert True
Here's my build pipeline:
trigger:
- '*'
pool:
vmImage: windows-latest
name: 'Azure Pipelines'
stages:
- stage: Build
jobs:
- job: RunPythonUnitTests
displayName: Test - Python Unit Tests
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.7'
architecture: 'x64'
- script: |
pip install pytest pytest-azurepipelines pyspark
pytest
displayName: 'Run tests'
The Run Tests
step is failing. The logs are showing the following errors:
============================= test session starts =============================
platform win32 -- Python 3.7.9, pytest-7.1.0, pluggy-1.0.0
rootdir: D:\a\1\s
plugins: azurepipelines-0.8.0
collected 1 item
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\site-packages\_pytest\main.py", line 268, in wrap_session
INTERNALERROR> session.exitstatus = doit(config, session) or 0
INTERNALERROR> File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\site-packages\_pytest\main.py", line 321, in _main
INTERNALERROR> config.hook.pytest_collection(session=session)
INTERNALERROR> File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\site-packages\pluggy\_hooks.py", line 265, in __call__
INTERNALERROR> return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
INTERNALERROR> File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\site-packages\pluggy\_manager.py", line 80, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR> File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\site-packages\pluggy\_callers.py", line 60, in _multicall
INTERNALERROR> return outcome.get_result()
INTERNALERROR> File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\site-packages\pluggy\_result.py", line 60, in get_result
INTERNALERROR> raise ex[1].with_traceback(ex[2])
INTERNALERROR> File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\site-packages\pluggy\_callers.py", line 39, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\site-packages\_pytest\main.py", line 332, in pytest_collection
INTERNALERROR> session.perform_collect()
INTERNALERROR> File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\site-packages\_pytest\main.py", line 659, in perform_collect
INTERNALERROR> self.config.pluginmanager.check_pending()
INTERNALERROR> File "c:\hostedtoolcache\windows\python\3.7.9\x64\lib\site-packages\pluggy\_manager.py", line 265, in check_pending
INTERNALERROR> % (name, hookimpl.plugin),
INTERNALERROR> pluggy._manager.PluginValidationError: unknown hook 'pytest_warning_captured' in plugin <module 'pytest_azurepipelines' from 'c:\\hostedtoolcache\\windows\\python\\3.7.9\\x64\\lib\\site-packages\\pytest_azurepipelines.py'>
Result Attachments will be stored in LogStore
Anyone know how to get around this?
Upvotes: 3
Views: 1517
Reputation: 3703
Looks like this was caused by a breaking change in the latest version of pytest
.
https://pypi.org/project/pytest/#history
Fixed it by specifying the previous version in the pipeline:
- script: |
pip install pytest==7.0.1 pytest-azurepipelines pyspark
pytest
Upvotes: 3