风起漂泊 发表于 2015-4-26 07:45:57

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()
页: [1]
查看完整版本: Python单元测试框架Pyunit 的使用