예제 #1
0
class TestCalc:
    def setup_class(self):
        self.cal = Calculator()

    @pytest.mark.parametrize(
        ['a', 'b', 'result'],
        yaml.safe_load(open("./data.yaml"))['add'],
        ids=['int', 'big num', 'xiaoshu', 'fushu', 'xiaoshu1'])
    def test_add(self, a, b, result):
        assert Decimal(result) == self.cal.add(a, b)

    @pytest.mark.parametrize(['a', 'b', 'result'],
                             yaml.safe_load(open('./data.yaml'))['sub'],
                             ids=['int', 'big num', 'xiaoshu', 'fushu'])
    def test_sub(self, a, b, result):
        assert Decimal(result) == self.cal.sub(a, b)

    @pytest.mark.parametrize(['a', 'b', 'result'],
                             yaml.safe_load(open('./data.yaml'))['mul'],
                             ids=['int', 'big num', 'xiaoshu', 'fushu'])
    def test_mul(self, a, b, result):
        assert Decimal(result) == self.cal.mul(a, b)

    @pytest.mark.parametrize(['a', 'b', 'result'],
                             yaml.safe_load(open('./data.yaml'))['div'],
                             ids=['int', 'big num', 'xiaoshu', 'fushu'])
    def test_div(self, a, b, result):
        assert Decimal(result) == self.cal.div(a, b)
class CheckCalc():
    def setup(self):
        self.cal = Calculator()

    # 加法
    @pytest.mark.first
    @pytest.mark.dependency()
    @pytest.mark.parametrize("a,b,result", adddatas, ids=addids)
    def check_add(self, a, b, result):
        print(f"\n计算数据:a={a},b={b},result={result}")
        assert self.cal.add(a, b) == result

    #除法
    @pytest.mark.last
    @pytest.mark.dependency(depends=["test_mul"])
    @pytest.mark.parametrize("a,b,result", divdatas, ids=divids)
    def check_div(self, a, b, result):
        print(f"\n计算数据:a={a},b={b},result={result}")
        assert self.cal.div(a, b) == result

    # 减法
    @pytest.mark.second
    @pytest.mark.dependency(depends=["test_add"])
    @pytest.mark.parametrize("a,b,result", subdatas, ids=subids)
    def check_sub(self, a, b, result):
        print(f"\n计算数据:a={a},b={b},result={result}")
        assert self.cal.sub(a, b) == result

    #乘法
    @pytest.mark.third
    @pytest.mark.dependency()
    @pytest.mark.parametrize("a,b,result", muldatas, ids=mulids)
    def check_mul(self, a, b, result):
        print(f"\n计算数据:a={a},b={b},result={result}")
        assert self.cal.mul(a, b) == result
예제 #3
0
class TestCalc1():
    def setup(self):
        self.cal = Calculator()

    @pytest.mark.add
    @pytest.mark.parametrize(('a', 'b', 'result'),
                             yaml.safe_load(open(r'../datas/calc.yml'))['add'])
    def test_add(self, a, b, result, open1):
        print(f"计算数据:  a={a}, b={b}, result={result}")
        assert self.cal.add(a, b) == result

    @pytest.mark.div
    @pytest.mark.parametrize(('a', 'b', 'result'),
                             yaml.safe_load(open(r'../datas/calc.yml'))['div'])
    def test_div(self, a, b, result, open1):
        print(f"计算数据:  a={a}, b={b}, result={result}")
        assert self.cal.div(a, b) == result

    @pytest.mark.mul
    @pytest.mark.parametrize(('a', 'b', 'result'),
                             yaml.safe_load(open(r'../datas/calc.yml'))['mul'])
    def test_mul(self, a, b, result, open1):
        print(f"计算数据:  a={a}, b={b}, result={result}")
        assert self.cal.mul(a, b) == result

    @pytest.mark.sub
    @pytest.mark.parametrize(('a', 'b', 'result'),
                             yaml.safe_load(open(r'../datas/calc.yml'))['sub'])
    def test_sub(self, a, b, result, open1):
        print(f"计算数据: a={a}, b={b}, result={result}")
        assert self.cal.sub(a, b) == result
예제 #4
0
class TestCalc:
    # 类级别 setup和teardown
    def setup_class(self):
        self.cal = Calculator()
        print("类级别 setup")

    def teardown_class(self):
        print("类级别 teardown")

    # 类里面的setup和teardown,运行在方法调用的前和后
    # 每条类里面的测试用例前后分别执行 setup和teardown
    def setup(self):
        print("setup")

    def teardown(self):
        print("teardown")

    @pytest.mark.add
    @pytest.mark.parametrize('a,b,result', [(1, 1, 2), (2, 2, 4),
                                            (100, 100, 200), (0.1, 0.1, 0.2),
                                            (-1, -1, -2)],
                             ids=["int", "int1", "bignun", "float", "fushu"])
    def test_add(self, a, b, result):
        # cal = Calculator()
        assert result == self.cal.add(a, b)

    @pytest.mark.add
    def test_add1(self):
        # cal = Calculator()
        assert 3 == self.cal.add(1, 2)

    @pytest.mark.div
    def test_div(self):
        # cal = Calculator()
        assert 1 == self.cal.div(1, 1)
예제 #5
0
 def test_sub(self,a,b,c):
     """
     减法测试用例
     :param a:
     :param b:
     :param c:
     :return:
     """
     cal = Calculator()
     print(f'\na,b,c的值:{a} - {b} = {c}')
     assert cal.sub(a,b) == c
예제 #6
0
 def test_add(self,a,b,c):
     """
     加法测试用例
     :param a:
     :param b:
     :param c:
     :return:
     """
     cal = Calculator()
     print(f'\na,b,c的值:{a} + {b} = {c}')
     assert cal.add(a,b) == c
예제 #7
0
class TestCalc:

    def setup_class(self):
        self.cal = Calculator()

    @pytest.mark.run(order=2)
    @pytest.mark.dependency(name="add")
    # @pytest.mark.xfail(reason="deliberate fail")
    @pytest.mark.parametrize('read', c, ids=ids_add, indirect=True)
    def check_add(self, read):
        print(f"计算:{read[0]} + {read[1]},预期结果为:{read[2]}")
        try:
            temp_result = self.cal.add(read[0], read[1])
            assert temp_result == read[2]
        except Exception as e:
            print(e)
            assert False

    @pytest.mark.run(order=3)
    @pytest.mark.dependency(depends=["add"])
    @pytest.mark.parametrize('read', c, ids=ids_sub, indirect=True)
    def check_sub(self, read):
        print(f"计算:{read[0]} - {read[1]},预期结果为:{read[3]}")
        try:
            temp_result = self.cal.sub(read[0], read[1])
            assert temp_result == read[3]
        except Exception as e:
            print(e)
            assert False

    @pytest.mark.run(order=4)
    @pytest.mark.dependency(name="mul")
    @pytest.mark.parametrize('read', c, ids=ids_mul, indirect=True)
    def check_mul(self, read):
        print(f"计算:{read[0]} * {read[1]},预期结果为:{read[4]}")
        try:
            temp_result = self.cal.mul(read[0], read[1])
            assert temp_result == read[4]
        except Exception as e:
            print(e)
            assert False

    @pytest.mark.run(order=5)
    @pytest.mark.dependency(depends=["mul"])
    @pytest.mark.parametrize('read', c, ids=ids_div, indirect=True)
    def check_div(self, read):
        print(f"计算:{read[0]} ÷ {read[1]},预期结果为:{read[5]}")
        try:
            temp_result = self.cal.div(read[0], read[1])
            assert temp_result == read[5]
        except Exception as e:
            print(e)
            assert False
예제 #8
0
 def test_mul(self,a,b,c):
     """
     乘法测试用例
     ((Decimal(a) * Decimal(b)).quantize(Decimal('0.00'))
     :param a:
     :param b:
     :param c:
     :return:
     """
     import decimal
     cal = Calculator()
     print(f'\na,b,c的值:{a} * {b} = {c}')
     assert cal.mul(a,b) == c
예제 #9
0
class TestCalc:
    # setup_class, teardown_class每个类里面 执行前后分别 执行
    def setup_class(self):
        self.cal = Calculator()
        print("类级别 setup")

    def teardown_class(self):
        print("类级别 teardown")

    # 函数级别 每条类里面的测试用例前和后分别 执行setup teardown
    def setup(self):
        print("setup")

    def teardown(self):
        print("teardown")

    @pytest.mark.parametrize('a, b, result', adddatas, ids=addids)
    # @pytest.mark.add
    def test_add(self, a, b, result):
        steps(a, b, result)
        # cal = Calculator()
        # assert result == self.cal.add(a, b)
        # assert result == self.cal.add1(a, b)
        # assert result == self.cal.add2(a, b)

    # @pytest.mark.add
    def test_add1(self):
        # cal = Calculator()
        assert 3 == self.cal.add(1, 2)

    # @pytest.mark.div
    @pytest.mark.parametrize('a,b,c', divdatas, ids=divids)
    def test_div(self, a, b, c):
        # cal = Calculator()
        print("登录操作111")
        assert c == self.cal.div(a, b)
        print("登录操作222")
        assert 1 == self.cal.div(2, 1)
        print("登录操作333")
        assert 1 == self.cal.div(2, 1)

    def test_assume(self):
        print("登录操作")
        pytest.assume(1 == 2)
        print("搜索操作")
        pytest.assume(2 == 2)
        print("加购操作")
        pytest.assume(3 == 2)
예제 #10
0
class TestCalc:
    # 定义setup_class()方法
    def setup_class(self):
        print("开始计算")
        # 实例化计算器
        self.calc = Calculator()

    # 定义teardown_class()方法
    def teardowm_class(self):
        print("结束计算")

    # 定义setup()方法
    def setup(self):
        print("要灵活使用")

    # 定义teardown()方法
    def teardowm(self):
        print("灵活使用结束")


    # 装饰器参数化  加法标记
    @pytest.mark.add
    @pytest.mark.parametrize('a,b,expect',[
        (1,1,2),
        (100,100,200),
        (0.1,0.1,0.2),
        (-1,-1,-2),
        ],ids=['int','bigint','float','minus'])
    # 定义一个test_add1()方法
    def test_add(self,a,b,expect):
        # 调用它的相加add()方法
         result=self.calc.add(a,b)
        # 判断result为小数的时候使用round取小数点后两位
         if isinstance(result,float):
             result=round(result,2)
        # 断言
         assert expect == result


    # 装饰器  yaml文件传入参数化
    @pytest.mark.div
    @pytest.mark.parametrize('a ,b,hope',mydatas,ids=myid)
    # 定义除法测试方法,传入参数和希望值
    def test_div(self,a,b,hope):
         # 除法结果
         result=self.calc.div(a,b)
         # 断言希望值是否等于除法结果
         assert hope == result
예제 #11
0
class TestCalc:
    cal = Calculator()

    @pytest.mark.parametrize('a,b,result', divdatas, ids=divids)
    @pytest.mark.run(order=3)
    @pytest.mark.dependency(depends=['test_mult'])
    def test_div(self, a, b, result):
        if b == 0:
            print("除数不能为0")
            return 0
        else:
            assert result == self.cal.div(a, b)

    @pytest.mark.parametrize('a,b,result', adddatas, ids=addids)
    @pytest.mark.run(order=0)
    @pytest.mark.dependency(name='test_add')
    def test_add(self, a, b, result):
        assert result == self.cal.add(a, b)

    @pytest.mark.parametrize('a,b,result', minusdatas, ids=minusids)
    @pytest.mark.run(order=1)
    @pytest.mark.dependency(depends=['test_add'])
    def test_minus(self, a, b, result):
        assert result == self.cal.minus(a, b)

    @pytest.mark.parametrize('a,b,result', multdatas, ids=multids)
    @pytest.mark.run(order=2)
    @pytest.mark.dependency(name='test_mult')
    def test_mult(self, a, b, result):
        assert result == self.cal.mult(a, b)
예제 #12
0
class Testcalc:
    def setup_class(self):
        self.calc = Calculator()
        print("开始计算")

    def teardown_class(self):
        print("计算结束")

    @pytest.mark.parametrize('a,b,expect', adddatas, ids=myid)
    def test_add(self, a, b, expect):
        result = self.calc.add(a, b)
        assert expect == result

    @pytest.mark.parametrize('a,b,expect', divdatas, ids=myid1)
    def test_div(self, a, b, expect):
        result = self.calc.div(a, b)
        assert expect == result
예제 #13
0
class TestCalc:
    # setup_class,teardown_class 类级别每个类里面执行前后分别执行
    def setup_class(self):
        self.cal = Calculator()
        print('类级别setup')

    def teardown_class(self):
        print('类级别teardown')

    # 方法级别,每个方法里面的测试用例前后分别执行setup、teardown
    def setup(self):
        # self.cal = Calculator()
        print('setup')

    def teardown(self):
        print('teardown')

    # 方法级别,每个方法里面的测试用例前后分别执行setup、teardown
    def setup_method(self):
        # self.cal = Calculator()
        print('方法级别setup')

    def teardown_method(self):
        print('方法级别teardown')

    @pytest.mark.add
    @pytest.mark.parametrize('a,b,result', [(1, 1, 3), (2, 2, 4),
                                            (100, 100, 200), (0.1, 0.1, 0.2),
                                            (-1, -1, -2)],
                             ids=['int', 'int', 'bignum', 'float',
                                  '负数'])  # 参数化
    def test_add(self, a, b, result):
        # cal = Calculator()
        assert result == self.cal.add(a, b)

    # @pytest.mark.add
    # @pytest.mark.parametrize('a,b,result', mydatas, ids=myids)
    # def test_add1(self,a,b,result):
    #     # cal = Calculator()
    #     assert result == self.cal.add(a, b)

    @pytest.mark.div
    def test_div(self):
        # cal = Calculator()
        assert 1 == self.cal.div(1, 1)
예제 #14
0
class TestCalc():
    def setup_class(self):
        self.cal = Calculator()

    def teardown_class(self):
        pass

    # @pytest.mark.parametrize("a, b, result",[
    #     (1,1,2),
    #     (-1,-1,-2),
    #     (-1,1,0)
    # ],)
    @pytest.mark.run(order=1)
    @pytest.mark.parametrize(('a,b,result'), add_datas, ids=adds)
    @pytest.mark.add
    def test_add(self, a, b, result):
        assert result == self.cal.add(a, b)

    # 插件pytest-dependency	控制用例依赖关系
    '''
    如果test_add用例成功,test_cut会被执行
    如果test_add用例失败,test_cut会被跳过不被执行
    depends = [] 列表中加入依赖得到用例名称
    '''
    # 插件pytest-ordering控制用例执行顺序
    @pytest.mark.run(order=2)
    @pytest.mark.dependency(depends=['test_add'], name='test_cut')
    @pytest.mark.parametrize('a,b,result', cut_datas, ids=cuts)
    @pytest.mark.cut
    def test_cut(self, a, b, result):
        assert result == self.cal.cut(a, b)

    @pytest.mark.run(order=3)
    @pytest.mark.parametrize('a,b,result', mult_datas, ids=mults)
    @pytest.mark.mult
    def test_mult(self, a, b, result):
        assert result == self.cal.mult(a, b)

    @pytest.mark.run(order=4)
    @pytest.mark.dependency(depends=['test_mult'], name='test_div')
    @pytest.mark.parametrize('a,b,result', div_datas, ids=divs)
    @pytest.mark.div
    def test_div(self, a, b, result):
        assert result == self.cal.div(a, b)
예제 #15
0
 def test_div(self,a,b,c):
     """
     除法测试用例
     :param a:
     :param b:
     :param c:
     :return:
     """
     with allure.step("实例化"):
         cal = Calculator()
     with allure.step("判断除数是否为0"):
         if b != 0:
             print(f'\na,b,c的值:{a} / {b} = {c}')
             assert cal.div(a,b) == c
         else:
             allure.attach("<body>这是一段html body块</body>", "html测试块", attachment_type=allure.attachment_type.HTML)
             allure.attach.file("../report/photo/a.jpg", name="这是图片", attachment_type=allure.attachment_type.JPG)
             allure.attach("除数不能为0!", attachment_type=allure.attachment_type.TEXT)
             print("除数不能为0!")
예제 #16
0
class TestCalc():
    def setup_class(self):
        print("开始计算")
        # 实例化计算器
        self.calc = Calculator()

    def teardown_class(self):
        print("结束计算")

    @pytest.mark.add
    def test_fun(self):
        # # 实例化计算器
        # calc = Calculator()
        # 调用它的相加方法
        result = self.calc.add(1, 1)
        # 断言
        assert 2 == result

    @pytest.mark.add
    @pytest.mark.parametrize("a,b,expect", adddatas, ids=myid)
    def test_add(self, a, b, expect):
        # # 实例化计算器
        # calc = Calculator()
        # 调用它的相加方法
        result = self.calc.add(a, b)
        # 如果结果是浮点数,四舍五入取两位
        if isinstance(result, float):
            result = round(result, 2)
        # 断言
        assert expect == result

    @pytest.mark.add
    def test_add1(self):
        # # 实例化计算器
        # calc = Calculator()
        # 调用它的相加方法
        result = self.calc.add(100, 100)
        # 断言
        assert 200 == result

    @pytest.mark.add
    def test_add2(self):
        # # 实例化计算器
        # calc = Calculator()
        # 调用它的相加方法
        result = self.calc.add(-1, -1)
        # 断言
        assert -2 == result

    @pytest.mark.div
    def test_div(self):
        # calc = Calculator()
        result = self.calc.div(1, 1)
        assert 1 == result

    @pytest.mark.div
    def test_div1(self):
        # calc = Calculator()
        result = self.calc.div(-1, 1)
        assert -1 == result
예제 #17
0
class TestCalc:
    def setup_method(self):
        self.cal = Calculator()
        print("setup_method")

    @pytest.mark.parametrize(("a", "b", "result"), [(1, 2, 3), (-1, 2, 1),
                                                    (-1, -2, 3), (0, 0, 0),
                                                    (0.5, 3, 3.5)])
    @pytest.mark.add
    def test_add(self, a, b, result, open):
        #cal = Calculator()
        assert self.cal.add(a, b) == result

    @pytest.mark.parametrize(("a", "b", "result"), [(1, 2, 3), (-1, 2, 1),
                                                    (-1, -2, 3), (0, 0, 0),
                                                    (0.5, 3, 3.5), (1, 0, 0),
                                                    (0, 1, 0)])
    @pytest.mark.div
    def test_div(self, a, b, result, open):
        cal = Calculator()
        assert self.cal.div(a, b) == result

    @pytest.mark.parametrize(("a", "b", "result"), [(1, 2, 3), (-1, 2, 1),
                                                    (-1, -2, 3), (0, 0, 0),
                                                    (0.5, 3, 3.5), (1, 0, 0),
                                                    (0, 1, 0)])
    @pytest.mark.subtraction
    def test_subtraction(self, a, b, result, open):
        #cal = Calculator()
        assert self.cal.subtraction(a, b) == result

    @pytest.mark.parametrize(("a", "b", "result"), [(1, 2, 3), (-1, 2, 1),
                                                    (-1, -2, 3), (0, 0, 0),
                                                    (0.5, 3, 3.5), (1, 0, 0),
                                                    (0, 1, 0)])
    @pytest.mark.multiplication
    def test_multiplication(self, a, b, result, open):

        assert self.cal.multiplication(a, b) == result
예제 #18
0
class TestCalc:

    # 类里面执行
    def setup_class(self):
        print("类级别setup")
        self.calc = Calculator()

    def teardown_class(self):
        print("类级别teardown")

    @pytest.mark.parametrize('list1',
                             yaml.safe_load(open('./../calc.yml'))['add'])
    def test_add(self, list1, calc):
        add_result = self.calc.add(list1[0], list1[1])
        print(f'实际结果为:{add_result}, 类型为{type(add_result)}')
        assert Decimal(list1[2]).quantize(Decimal('0.00')) == add_result

    @pytest.mark.parametrize('list1',
                             yaml.safe_load(open('./../calc.yml'))['div'])
    def test_div(self, list1, calc):
        assert Decimal(list1[2]).quantize(Decimal('0.00')) == self.calc.div(
            list1[0], list1[1])

    @pytest.mark.parametrize('list1',
                             yaml.safe_load(open('./../calc.yml'))['decrease'])
    def test_decrease(self, list1, calc):
        assert Decimal(list1[2]).quantize(
            Decimal('0.00')) == self.calc.decrease(list1[0], list1[1])

    @pytest.mark.parametrize('list1',
                             yaml.safe_load(
                                 open('./../calc.yml'))['multiplication'])
    def test_multiplication(self, list1, calc):
        print(list1)
        assert Decimal(list1[2]).quantize(
            Decimal('0.00')) == self.calc.multiplication(list1[0], list1[1])
예제 #19
0
class TestCal:
    def setup(self):
        self.cal = Calculator()
        print("初始化一个计算机对象")

    def teardown(self):
        print("结束")

    @pytest.mark.add
    @pytest.mark.parametrize('a,b,result', [(1, 1, 2), (0.2, 0.2, 0.4)],
                             ids=['int', 'float'])  #给用例命名
    def test_add01(self, a, b, result):
        # cal = Calculator()
        assert result == self.cal.add(a, b)

    @pytest.mark.add
    def test_add02(self):
        # cal = Calculator()
        assert 4 == self.cal.add(2, 2)

    @pytest.mark.div
    def test_div(self):
        # cal = Calculator()
        assert 1 == self.cal.div(2, 2)
예제 #20
0
class CheckCalc():

    def setup(self):
        self.cal = Calculator()

    @pytest.mark.parametrize("a,b,result", adddatas, ids=addids)
    def check_add(self, a, b, result):
        print(f"\n计算数据:a={a},b={b},result={result}")
        assert self.cal.add(a, b) == result

    @pytest.mark.parametrize("a,b,result", divdatas, ids=divids)
    def check_div(self, a, b, result):
        print(f"\n计算数据:a={a},b={b},result={result}")
        assert self.cal.div(a, b) == result

    @pytest.mark.parametrize("a,b,result", subdatas, ids=subids)
    def check_sub(self, a, b, result):
        print(f"\n计算数据:a={a},b={b},result={result}")
        assert self.cal.sub(a, b) == result

    @pytest.mark.parametrize("a,b,result", muldatas, ids=mulids)
    def check_mul(self, a, b, result):
        print(f"\n计算数据:a={a},b={b},result={result}")
        assert self.cal.mul(a, b) == result
예제 #21
0
class TestCalculator():
    cal = Calculator()

    def test_add(self):
        assert 2 == self.cal.add(1, 1)

    def test_power(self):
        assert 4 == self.cal.power(2)

    def test_sqrt(self):
        assert 3 == self.cal.sqrt(9)

    def test_mod(self):
        assert 2 == self.cal.mod(10, 4)

    def test_divisibility(self):
        assert 2 == self.cal.divisibility(7, 3)
예제 #22
0
class TestCalc:
    # setup_class, teardown_class每个类里面 执行前后分别 执行
    def setup_class(self):
        self.cal = Calculator()
        print("类级别 setup")

    def teardown_class(self):
        print("类级别 teardown")

    # 函数级别 每条类里面的测试用例前和后分别 执行setup teardown
    def setup(self):
        print("setup")

    def teardown(self):
        print("teardown")

    @pytest.mark.parametrize('a, b, result', [
        (1, 1, 3),
        (2, 2, 4),
        (100, 100, 200),
        (0.1, 0.1, 0.2),
        (-1, -1, -2)
    ]
        , ids=['int', 'int', 'bignum', 'float', 'fushu'])
    # @pytest.mark.add
    def test_add(self, a, b, result):
        # cal = Calculator()
        assert result == self.cal.add(a, b)
        assert result == self.cal.add(a, b)
        assert result == self.cal.add(a, b)

    # @pytest.mark.add
    def test_add1(self):
        # cal = Calculator()
        assert 3 == self.cal.add(1, 2)

    # @pytest.mark.div
    def test_div(self):
        # cal = Calculator()
        print("登录操作111")
        assert 1 == self.cal.div(2, 1)
        print("登录操作222")
        assert 1 == self.cal.div(2, 1)
        print("登录操作333")
        assert 1 == self.cal.div(2, 1)

    def test_assume(self):
        print("登录操作")
        pytest.assume(1 == 2)
        print("搜索操作")
        pytest.assume(2 == 2)
        print("加购操作")
        pytest.assume(3 == 2)
예제 #23
0
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import pytest
import yaml

from pythoncode.calc import Calculator

cal = Calculator()


def get_testDatas():
    with open(file="./datas/testDatas.yaml", mode="r") as f:
        testDatas = yaml.safe_load(f)
        print(type(testDatas))
        print(testDatas)
        return testDatas


def get_steps():
    with open(file="./datas/steps.yaml", mode="r") as f:
        add_datas = []
        div_datas = []
        stepDatas = yaml.safe_load(f)
        testDatas = get_testDatas()
        for step in stepDatas:
            if step == "add":
                for key in testDatas.keys():
                    if key[:3] == step:
                        add_datas.append(testDatas[key])
            elif step == "div":
                for key in testDatas.keys():
예제 #24
0
 def setup_method(self):
     self.cal = Calculator()
     print("setup_method")
예제 #25
0
 def test_div(self, a, b, result, open):
     cal = Calculator()
     assert self.cal.div(a, b) == result
예제 #26
0
 def test_div(self):
     cal = Calculator()
     assert cal.div(4, 2) == 2
예제 #27
0
 def test_add1(self, a, b, result):
     cal = Calculator()
     assert cal.add(a, b) == result
예제 #28
0
 def test_add(self):
     cal = Calculator()
     assert cal.add(1, 1) == 2
예제 #29
0
def test_add4():
    cal = Calculator()
    assert cal.add(3, 4) == 7
예제 #30
0
def get_calc():
    print("计算开始")
    calc = Calculator()
    yield calc
    print("计算结束")