pytest 中添加线程
#D:\pythonProject0726\test_case\test_one.py import time def setup_module(): print('准备测试数据') def teardown_module(): print('清理测试数据') def test_one(): ex=1 real=1 time.sleep(3) print('1==1') assert ex==real
# D:\pythonProject0726\test_case\test_two.py import time def setup_module(): print('准备测试数据2') def teardown_module(): print('清理测试数据2') def test_one(): ex=1 real=1 time.sleep(3) print('1==1') assert ex==real
# D:\pythonProject0726\test_case\all_test_case.py import pytest import xdist if __name__ == '__main__': pytest.main(['-vs'])
终端中
pytest -vs test_case
终端中:
# 下载插件
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pytest-xdist
# 执行 详细的 线程为2的 整个test_case里的全部的test_开头的py文件
pytest -vs test_case -n 2