python单元测试

Auto.py文件 测试文件 from widget import Widget import unittest class mytestproject1(unittest.TestCase): def setUp(self): self.widget = Widget() def testcase1(self): # self.assertEquals(7/2,3) self.assertEquals(self.widget.getSize(),(50,40)) # 测试 if __name__ == "__main__": unittest.main() 类文件 #!/usr/bin/env python要有这行 class Widget(): def __init__(self, size =(40,40)): self._size = size def getSize(self): return self._size

你可能感兴趣的:(python单元测试)