python-3.x - 并行运行测试时仅运行一次 pytest 夹具
问题描述
当测试通过 shell 脚本并行运行时,我在 conftest 文件中仅运行一次 pytest 夹具时遇到了一些真正的困难。shell脚本的内容如下:
#!/usr/bin/env bash
pytest -k 'mobile' --os iphone my_tests/ &
pytest -k 'mobile' --os ipad my_tests/
wait
pytest 夹具在运行测试之前为手机测试创建资源:
@pytest.fixture(scope='session', autouse=True)
def create_resources():
// Do stuff to create the resources
yield
// Do stuff to remove the resources
当每个单独运行时,它都能完美运行。创建资源,运行测试并最终删除它创建的资源。当并行运行(使用 shell 脚本)时,两者都尝试同时运行 create_resources 固定装置。
有谁知道我可以只运行一次 create_resource 夹具的方法吗?如果是这样,那么第二个设备是否有可能等到所有设备运行测试之前创建资源?
解决方案
推荐阅读
- mysql - 排序后的 json 数组字段
- heroku - 烧瓶和heroku的访问问题
- android - Cannot run existing Android Project com.android.tools:common:25.3.3
- html - 使用 PowerShell 从 HTML 中的选项卡式表格中提取信息
- testing - 如何测试以确保我的应用程序在部署升级期间是安全的?
- excel - 在由 bing 提供支持的 excel 地图中,未加载州 IN 和 MN 的等值线地图数据
- python - socket模块发送接收类型错误
- c# - ssis 检查文件是否存在
- java - 我现在如何在 javafx 中为 textArea 输入字符的索引
- google-analytics - 通过 GTM 和 Google Analytics 在 AMP 页面上跟踪链接的问题