Python单元测试框架Pyunit 的使用


Python单元测试框架Pyunit 使用示例:

 1 import unittest
 2 
 3 class Person:
 4     def age(self):
 5         return 34
 6     def name(self):
 7         return 'bob'
 8     
 9 class TestSequenceFunctions(unittest.TestCase):
10     
11     def setUp(self):
12         self.man = Person()
13         print 'set up now'
14         
15 
16     def test1(self):
17         self.assertEqual(self.man.age(), 34)
18 
19     def test2(self):
20         self.assertEqual(self.man.name(), 'bob')
21 
22     def test3(self):
23         self.assertEqual(4+78,23)
24 
25 if __name__ == '__main__':
26     unittest.main()


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM