使用unittest进行测试,如果是需要实现上百个测试用例,把它们全部写在一个test.py文件中,文件会越来越臃肿,后期维护页麻烦.此时可以将这些用例按照测试功能进行拆分,分散到不同的测试文件中. Python代码如下: testadd.py: from calculator import Math import unittest class TestAdd(unittest.TestCase): def setUp(self): print("test case start") d
一.断言方法 方法 检查 版本 assertEqual(a,b) a==b assertNotEqual(a,b) a!=b assertTrue(x) bool(x) is True assertFalse(x) bool(x) is False assertIs(a,b) a is b 3.1 assertIsNot(a,b) a is not b 3.1 assertIsNone(x) x is None 3.1 assertIsNotNone(x) x is not No