数据2101王庆洋
信计2001孙恒丰 test_作业 · 孙恒丰/sunhengfeng - 码云 - 开源中国 (gitee.com) demo_test.py · 孙恒丰/sunhengfeng - 码云 - 开源中国 (gitee.com)
数据2101李明洋
信计2002于爽200350221https://gitee.com/frost-white-on-the-ground/text.git
信计2002刘冬冬
def add(num1, num2):
“”“计算两个数的和”“”
try:
return round(num1 + num2, 2)
except TypeError:
return ‘参数类型错误’
except ValueError:
return ‘参数数值不合法’
import pytest
import allure
from calculator import add
@pytest.fixture(params=[
[1, 2, 3],
[-1, 0, -1],
[0, 0, 0],
[1.1, 2.2, 3.3],
[-1.1, 2.2, 1.1],
[0.01, 0.02, 0.03],
[-99, 99, 0],
[99, -99, 0],
[0, 99, 99],
[99, 0, 99],
[99, 99, 198],
[699, -600, 99],
[-0.01, 0.01, 0],
[0.01, -0.01, 0],
[0.1, 0.2, 0.3],
[1.23, 4.56, 5.79]
])
def test_data(request):
return request.param
@allure.step(‘计算 {0} + {1} = {2}’)
def test_add(test_data):
num1, num2, expected = test_data
allure.attach(f"被测数据:{test_data}")
with allure.step(‘开始计算’):
assert add(num1, num2) == expected
with allure.step(‘结束计算’):
pass
@pytest.mark.hebeu
def test_add_tag():
pass
pytest -m ‘hebeu’ --alluredir=allure-results
allure serve allure-results