python-3.x - PyTest:如何使用特定标记运行特定脚本
问题描述
我想要实现的是运行 python 测试脚本,但我想控制哪些测试正在通过@pytest.mark
夹具运行。到目前为止我所做的是:
pytest.ini
像这样在文件中定义标记:[pytest]
markers=[omni,milestone,release]
在测试模块脚本中,我定义了 2 种测试方法:
- test_1 用 :
@pytest.mark.omni
标记 - test_2 标有:
@pytest.mark.release
标记我正在尝试以以下方式执行代码:在模块的末尾,我放置了这段代码:
- test_1 用 :
if __name__ == "__main__":
import pytest
junit_path = os.path.join(tmp_folder, 'reports', 'Junit_p1_' + os.environ['COMPUTERNAME'] + '_' + time.strftime( "%d%m%Y_%H%M%S") + '.xml')
exit_code = pytest.main(['-vv', '--cache-clear', 'p1.py', '--durations=0', '--junitxml', junit_path, '--tb' ,'long']) # full execution
sys.exit(exit_code)
我通过调用调用模块
python p1.py
我正在尝试找出可以在pytest.main
调用侧添加标记过滤器的位置,以便从测试中运行特定标记
解决方案
推荐阅读
- ibm-mq - 有没有办法从频道名称中找到队列管理器名称?
- email - Microsoft Office Outlook 邮件搜索
- r - 并行包在另一个 R 包中使用时初始化非常慢
- javascript - React Ant Tooltip onHover 选择值
- firebase - 我的 AdMob 代码无法正常工作,因为我将其链接到 Firebase
- html - 将 .txt 文件转换为 HTML
- linux - PUTTY 未连接
- javascript - 在 React 中返回带有图像的图像标签
- r - 当其中一个具有 aspect.ratio = 1 时对齐两个 ggplot
- r - 如何在 data.table 中使用 str_glue(环境问题)