allure_pytest:AttributeError: ‘str‘ object has no attribute ‘iter_parents‘

踩坑记录

问题描述:

接口自动化测试时出现报错,报错文件是allure_pytest库

问题分析:

自动化测试框架是比较成熟的代码,报错也不是自己写的文件,而是第三方库,首先推测是allure_pytest和某些库有版本不兼容的问题

搜索发现,pytest 8.2.0 和 8.1.0 的几个版本会破坏 allure 的 listener 导致虚拟机上执行报错,需把pytest 回退到8.0.2

解决方案:

复制代码
pip uninstall pytest

pip install pytest==8.0.2

回退后,执行正常

相关推荐
姚青&13 天前
PyCharm 配置与界面化运行
pytest
姚青&13 天前
Pytest 测试用例断言
测试用例·pytest
姚青&13 天前
Pytest 命名规则
pytest
姚青&13 天前
Pytest 测试用例结构
测试用例·pytest
姚青&13 天前
Pytest 简介、安装与环境准备
pytest
测试渣14 天前
持续集成中的自动化测试框架优化实战指南
python·ci/cd·单元测试·自动化·pytest
小凯1234515 天前
pytest框架-详解(学习pytest框架这一篇就够了)
python·学习·pytest
逻极15 天前
pytest 入门指南:Python 测试框架从零到一(2025 实战版)
开发语言·python·pytest