python - pytest - 在单独的进程中运行每个测试
问题描述
我正在使用 pytest 运行大量的 python 测试,一些测试结果取决于测试的运行顺序。例如,如果测试 B 在测试 A 之后运行,那么它可能会由于测试 A 中完成的一些影响测试 B 的初始化而失败。为了规避这个问题,我想在新进程中运行每个测试,但测试仍应按顺序运行并且不是并行的。有没有办法用pytest做到这一点?
解决方案
@pytest.mark.order2
def test_foo():
assert True
@pytest.mark.order1
def test_bar():
assert True
推荐阅读
- c# - WebGrid 分页不起作用
- javascript - 切换聚合物 3 中的 Div
- google-apps-script - Google CacheService putAll() 在 put 的地方不起作用
- javascript - 为什么 string.replace() 不适用于包含括号的字符串?
- javascript - 在删除按钮上引导多个数据切换?
- python - 如何根据子字符串对字符串的python列表进行排序
- tensorflow - 如何在 COCO 数据集上加载预训练模型进行图像分割?
- html - 在加载所有页面之前先加载 SCRIPT
- php - 如何提取特殊字符之间的字符串?
- java - Appioum:无法使用(URL,功能)创建 AndroidDriver