def test_div_fu(self): assert div(10, -1) == -10 # allure + pytest 报告中插入图片方法,详细见allure官方文档 allure.attach.file('C:\\Users\\jiangzhw01\\Desktop\\12345.png', attachment_type=allure.attachment_type.PNG)
def test_div_exc(self): # 不会出现商业报错,崩溃 assert div(10, 'a') assert div('a', 10)
def test_div_zero(self): with pytest.raises(ZeroDivisionError): div(10, 0)
def test_div_int_param(self, num1, num2, res): assert div(num1, num2) == res
def test_div_float(self): # 结果是浮点数,a,b本身就是浮点数 assert div(10, 3) == 3.33 assert div(10.2, 0.2) == 50.1
def test_div_1(self): """ b>0 :return: """ assert div(1, 1) == 1
def test_div_int(self): assert div(10, 2) == 5 assert div(10, 5) == 2 assert div(1000000000, 1) == 1000000000
def test_div_6(self): """ a<0 :return: """ assert div(-1, 1) == -1
def test_div_5(self): """ a=0 :return: """ assert div(0, 1) == 0
def test_div_4(self): """ a>0 :return: """ assert div(1, 1) == 1
def test_div_3(self): """ b<0 :return: """ assert div(1, -1) == -1
def test_div_2(self): """ b=0 :return: """ assert div(1, 0) is None