示例#1
0
 def test_add(self):
     c = Calculator(6,3)
     result = c.add()
     # assert result==9,'加法运算失败!'
     # TestCalculator().assertEqual(result,9)
     self.assertEqual(result,9)
     print('test_add finished!')
示例#2
0
    def test_div(self):
        c = Calculator(6, 2)
        result = c.div()
        #assert result==3,'除法运算失败!'
        TestCalculator().assertEqual(result, 3)
        print('test_div finished!')


# if __name__ =='__main__':
# #
# #
# #         # 创建测试套件,并添加用例到套件
# #         suit = unittest.TestSuite()
# #
# #         # 4)添加一个模块(导入当前目录的模块???)
# #         loader = unittest.TestLoader()
# #         suit.addTest(loader.loadTestsFromModule(test_calculator))
# #
# #         #创建测试运行器
# #         runner = unittest.TextTestRunner()
# #         runner.run(suit)
示例#3
0
 def test_mul(self):
     c = Calculator(2,3)
     result = c.mul()
     # assert result==6,'乘法运算失败!'
     TestCalculator().assertEqual(result, 6)
     print('test_mul finished!')
示例#4
0
 def test_sub(self):
     c = Calculator(6,3)
     result = c.sub()
     # assert result==3,'减法运算失败!'
     TestCalculator().assertEqual(result, 3)
     print('test_sub finished!')
示例#5
0
 def test_sub_string(self):
     c = Calculator("6", "3")
     result = c.sub()
     self.assertEqual(result, 3)
     print("test_sub_string finish")
示例#6
0
 def test_sub_decimals(self):
     c = Calculator(6.9, 3.9)
     result = c.sub()
     self.assertEqual(result, 3)
     print("test_sub_decimals finish")
示例#7
0
 def test_sub_integer(self):
     c = Calculator(6, 3)
     result = c.sub()
     self.assertEqual(result, 3)
     print("test_sub_integer finish")
示例#8
0
 def test_add_string(self):
     c = Calculator("6", "3")
     result = c.add()
     self.assertEqual(result, 9)
     print("test_add_string finish")
示例#9
0
 def test_add_decimals(self):
     c = Calculator(6.1, 3.9)
     result = c.add()
     self.assertEqual(result, 9)
     print("test_add_decimals finish")
示例#10
0
 def test_add_integer(self):
     c = Calculator(6, 3)
     result = c.add()
     self.assertEqual(result, 9)
     print("test_add_integer finish")