'''
TDD: test drive develop
'''
import unittest
import util_m
class myunittestclass(unittest.TestCase):
'''must be the child class of unittest.TestCase'''
values=[1,2,3,4,5,6,7,10]
def test_is_less_than_10(self):
'''it is one test case example'''
for number in self.values:
result = util_m.is_less_than10(number)
self.assertEqual(result, 1)
'''assertEqual is on api of TestCase'''
def test_is_between_5_to_15(self):
for number in self.values:
result = util_m.is_between_5_to_15(number)
self.assertEqual(result,1)
if __name__ == '__main__':
unittest.main()
'''when running .py to test, this api will be called'''
Python---unit test
最新推荐文章于 2022-04-16 14:22:12 发布