import unittest
def sum_number(a, b):
return a + b
class MyTestCase(unittest.TestCase):
# def test_something(self):
# self.assertEqual(True, False)
@classmethod
def setUpClass(cls) -> None: # setupClass方法可以保证测试用例执行之前默认执行一次
print('setupClass')
def setUp(self) -> None:
print('setup')
def test_sum_int(self):
self.assertEqual(sum_number(1, 2), 3)
self.assertEqual(sum_number(100, 200), 300)
def test_sum_number(self):
self.assertEqual((1.1, 2.2), 3.3)
@classmethod
def tearDownClass(cls) -> None: # tearDownClass方法可以保证测试用例执行之后默认执行一次
print('tearDownClass')
def tearDown(self) -> None:
print('tearDown')
if __name__ == '__main__':
unittest.main()