You cannot access banned topics.
背景
在用 pytes 做自动化测试的时候,有时候我们的用例会非常多,可能每个用例又会有 IO 等待。如果顺序运行的话,就会很耗时。所以希望可以并发运行用例。这时可以考虑用多线程插件 pytest-parallel,它可以比 pytest-xdist 多进程版本有更高的并发。但是 pytest-parallel 无法和测试报告插件 allure-pytest 一起使用。它会导致 allure-pytest 无法正常生成测试报告。所以写了这个 pytest-multithreading-allure 插件兼容这个问题
使用示例
allure-pytest 和 pytest-parallel 网上都有很多教程,这里不做介绍,直接贴一个简单的代码实例
import time
import pytest
import allure
@allure.title("测试用例1")
def test_a_01():
print("----------------->>> test_a_01")
time.sleep(1)
assert 1
@allure.title("测试用例2")
def test_a_02():
print("----------------->>> test_a_02")
time.sleep(1)
assert 1
if __name__ == "__main__":
pytest.main(["-s", "test_allure.py","--tests-per-worker=2","--alluredir", "report/"])
没安装 pytest-multithreading-allure 插件之前运行这个代码,不会在 report 文件夹生成 allure 的测试报告。安装 pip install pytest-multithreading-allure 插件后,allure 的使用方式不变。再次运行上面的代码,可以在 report 文件夹生成测试报告了
「All right reserved, any unauthorized reproduction or transfer is prohibitted」
你好,装了插件以后,alllure.dynamic.title alllure.dynamic.description 好像都不生效了,报告里的 title 和 description 没法改变
取消了 threading.local() 后,会导致 allure 的一些装饰器失效啊兄弟,这块现在修复了么

为什么可以收集到用例但是没有用例运行
Python3.8.10
allure-pytest 2.11.1
pytest-multithreading 1.0.2
pytest-multithreading-allure 1.0.5
pytest-parallel 0.0.10
(venv) PS C:\Users\hli\Documents\Python\demo> pytest --tests-per-worker 20 --alluredir report
============================================================================================================= test session starts ==============================================================================================================
platform win32 -- Python 3.8.10, pytest-7.1.3, pluggy-1.0.0
rootdir: C:\Users\hli\Documents\Python\demo
plugins: allure-pytest-2.11.1, multithreading-1.0.2, multithreading-allure-1.0.5, parallel-0.0.10
collected 20 items
pytest-parallel: 1 worker (process), 20 tests per worker (threads)
============================================================================================================ no tests ran in 0.03s =============================================================================================================
嗨,这个现在改好了,升级就行了,pip install --upgrade pytest-multithreading-allure
你这个现在还有问题吗?这个看起来和插件没什么关系的
这个现在改好了,升级就行了,pip install --upgrade pytest-multithreading-allure
求助一下大佬,如果是 3.9.0 的版本这个插件可以使用吗,我使用的情况下发现有 unrecognized arguments: --tests-per-worker=auto