Пример #1
0
class CountTest(unittest.TestCase):
    """docstring for CountTest"""

    # 初始化计算器
    def setUp(self):
        self.cal = Calculator(8, 4)

    def tearDown(self):
        pass

    def test_add(self):
        result = self.cal.add()
        self.assertEqual(result, 12)

    def test_sub(self):
        result = self.cal.sub()
        self.assertEqual(result, 4)

    def test_mul(self):
        result = self.cal.mul()
        self.assertEqual(result, 32)

    def test_div(self):
        result = self.cal.div()
        self.assertEqual(result, 2)
Пример #2
0
class TestCalculator(unittest.TestCase):

    def setUp(self):
        self.cal = Calculator(8,4)


    def tearDown(self):
        pass

    def test_add(self):
        result = self.cal.add()
        self.assertEqual(result,12)

    def test_sub(self):
        result = self.cal.sub()
        self.assertEqual(result,4)


    def test_mul(self):
        result = self.cal.mul()
        self.assertEqual(result,32)

    def test_div(self):
        result = self.cal.div()
        self.assertEqual(result,1)
Пример #3
0
 def test_add(self):
     try:
         c = Calculator(2,4)
         result = c.add()
         assert(result == 6),'Integer addition result error!'
     except AssertionError as msg:
         print(msg)
     else:
         print('test pass!')
Пример #4
0
 def test_add(self):
     c = Calculator(2, 4)
     result = c.add()
     self.assertEqual(result, 6)