Exemple #1
0
class TestMathMethods(unittest.TestCase):
    def setUp(self):
        self.unit = MathMethods()

    def tearDown(self):
        del self.unit

    def test_add_two_zero(self):
        res = self.unit.add(0, 0)
        print('两个0相加', res)
        self.assertEqual(0, res)

    def test_add_two_positive(self):
        res = self.unit.add(1, 8)
        print('两个正数相加', res)
        self.assertEqual(9, res)

    def test_add_two_negative(self):
        res = self.unit.add(-1, -4)
        print('两个负数相加', res)
        self.assertEqual(-5, res)
Exemple #2
0
 def setUp(self):
     self.unit = MathMethods()
Exemple #3
0
 def test_add_two_negative(self):
     res = MathMethods().add(-1, -4)
     print('两个负数相加', res)
     self.assertEqual(-5, res)
Exemple #4
0
 def test_add_two_zero(self):
     res = MathMethods().add(0, 0)
     print('两个0相加', res)
     self.assertEqual(0, res)
Exemple #5
0
 def test_add_two_positive(self):
     res = MathMethods().add(1, 8)
     print('两个正数相加', res)
     self.assertEqual(9, res)