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