import pytest
class TestCalculator:
def setup(self):
self.cal = Calculator()
print("开始计算---------")
def teardown(self):
print("结束计算---------")
def teardown_class(self):
print("结束测试----------")
@pytest.mark.case_p0
def test_add_p0_01(self):
result = self.cal.add(1,1)
print("result---", result)
# 实际结果 与 预期结果 对比
assert result == 2
@pytest.mark.case_p0
def test_add_p0_02(self):
result = self.cal.add(-0.01,0.02)
print("result---", result)
# 实际结果 与 预期结果 对比
assert result == 0.01
@pytest.mark.case_p0
def test_add_p0_03(self):
result = self.cal.add(10,0.02)
print("result---", result)
# 实际结果 与 预期结果 对比
assert result == 10.02
@pytest.mark.case_p1
def test_add_p1_01(self):
result = self.cal.add(99,98.99)
print("result---", result)
# 实际结果 与 预期结果 对比
assert result == 197.99
@pytest.mark.case_p1
def test_add_p1_02(self):
result = self.cal.add(-99,98.99)
print("result---", result)
# 实际结果 与 预期结果 对比
assert result == -0.01
@pytest.mark.case_p1
def test_add_p1_03(self):
result = self.cal.add(98,99)
print("result---", result)
# 实际结果 与 预期结果 对比
assert result == 197
@pytest.mark.case_p1
def test_add_p1_04(self):
result = self.cal.add(-98.99,-99)
print("result---", result)
# 实际结果 与 预期结果 对比
assert result == -197.99