[英]pytest fails on Azure Devops under python 3.7 but passes under 3.8
我目前正在 python 应用程序上运行一套 37 pytest
测试。 我正在python 3.7.2
下构建,并且在本地所有测试都通过了。 在 Azure DevOps 管道上,我还测试了python 3.8
。 这是azure-pipelines.yml
:
trigger:
- dev
pool:
vmImage: 'ubuntu-latest'
strategy:
matrix:
Python37:
python.version: '3.7'
Python38:
python.version: '3.8'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(python.version)'
displayName: 'Use Python $(python.version)'
- script: |
python -m pip install --upgrade pip
pip install -r requirements.txt
displayName: 'Install dependencies'
- script: |
pip install pytest pytest-azurepipelines
pytest
displayName: 'pytest'
在3.7
运行下,我有一个特定的测试在assert
上失败,但实际计算值:
self = <unit_tests.test_services_string_jb_router.TestServicesRectilinearRouter object at 0x7f5404e88fd0>
def test_create_block_when_called_calculates_correct_total_string_cable_length(self):
designer = BlockDesigner(CsvStore(self.config), self.router, self.config)
block = designer.create_block("BK1")
result = block.total_cable_length
> assert result == 4943.176
E assert 4932.926 == 4943.176
unit_tests/test_services_string_jb_router.py:28: AssertionError
然而,该测试在3.8
运行下通过。
代码产生一个实际值,只是一个错误的事实,这表明它得到了一个不正确的配置,但只在python 3.7
而不是python 3.8
下! .
我在带有str(pathlib.Path(__file__).parent.absolute())
前缀的测试类的开头运行setup_method
以确保跨平台兼容性。
我什至从哪里开始寻找这个问题?
...然后它就过去了,我没有做任何事情。 假设它是一些较旧的配置,并且在 Azure 某处未清除缓存。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.