加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
test_parameterize.py 817 Bytes
一键复制 编辑 原始数据 按行查看 历史
zengjx 提交于 2024-04-21 11:14 . 首次
import pytest
import math
class TestPow:
# pytest 参数化
@pytest.mark.parametrize(
"base,exponent,expected",
[(2, 2, 4), (3, 3, 27), (1, 9, 1), (0, 9, 0)],
ids=["case1", "case2", "case3", "case4"])
def test_pow(self,base, exponent, expected):
print(base, exponent, expected)
assert math.pow(base, exponent) == expected
@pytest.mark.parametrize(
"ip,port,ip2,port2",
[("192.1.168.666", 13400,"192.168.1.1" ,0x456), ("192.1.168.666", 13,"192.168.1.1" ,0x456),
("192.1.168.666", 13400,"192.168.1.1" ,0x46), ("192.1.168.666", 134,"192.168.1.1" ,0x8888)],
ids=["case1", "case2", "case3", "case4"])
def test_1(self,ip,port,ip2,port2):
print(ip,port,ip2,port2)
if __name__ == '__main__':
pytest.main(['-sv'])
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化