Python中文
首页
教程
问答
标签
搜索
登录
注册
在parametriz中使用fixture作为参数的pytest
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>我想使用fixture作为<code>pytest.mark.parametrize</code>的参数或具有相同结果的参数。</p> <p>例如:</p> <pre><code>import pytest import my_package @pytest.fixture def dir1_fixture(): return '/dir1' @pytest.fixture def dir2_fixture(): return '/dir2' @pytest.parametrize('dirname, expected', [(dir1_fixture, 'expected1'), (dir2_fixture, 'expected2')] def test_directory_command(dirname, expected): result = my_package.directory_command(dirname) assert result == expected </code></pre> <p>fixture param s的问题是,fixture的每个参数在每次使用时都会运行,但我不希望这样。我想能够选择哪些设备将使用取决于测试。</p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>pytest当前不支持此操作。但是有一个开放的特性请求:<a href="https://github.com/pytest-dev/pytest/issues/349" rel="noreferrer">https://github.com/pytest-dev/pytest/issues/349</a>。</p>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
拆分()错误:列表索引超出范围
5 回答
拆分(分解)数据帧字符串条目以分隔行
1 回答
拆分(分解)数据帧字符串条目以分隔行。多列
2 回答
拆分/提取系列索引中的字符串并作为DataFram展开
3 回答
拆分/标识字符串末尾的数字,该数字没有固定的字符数
8 回答
拆分2列CSV并保存到不同的文件
5 回答
拆分aconftest.py分成几个较小的conftestlike部分
10 回答
拆分apyspark.sql基于一列将数据帧放入多个表中
10 回答
拆分ascii/unicode字符串
4 回答
拆分a稀疏稀疏矩阵进入列车和tes
1 回答
拆分B的可能性
2 回答
拆分char上的查询字符串以获取不同的参数;Python:
3 回答
拆分csv fi中显示的图表
1 回答
拆分csv fi的列
9 回答
拆分CSV-fi需要Regex帮助
1 回答
拆分csv(和多选字段)以获取要导出到xlsx工作表的字段计数,我会不断获取“[blank]值和nan
2 回答
拆分CSV文件时出现标题问题[Python 3]
4 回答
拆分Cython代码后无法转换为Python对象
3 回答
拆分Dataframe,让线程处理每个部分,然后合并Datafram
3 回答
拆分dataframe列并删除额外变量
4 回答