本文实例讲述了Python之PyUnit单元测试,与erlang eunit单元测试很像,分享给大家供大家参考。具体方法如下:
1.widget.py文件如下:
jobin@jobin-desktop:~/work/python/py_unit$ python auto.py
F
======================================================================
FAIL: testSize (__main__.WidgetTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "auto.py", line 15, in testSize
self.assertEqual(self.widget.getSize(), (50, 40))
AssertionError: (40, 40) != (50, 40)
----------------------------------------------------------------------
Ran 1 test in 0.000s
FAILED (failures=1)
jobin@jobin-desktop:~/work/python/py_unit$[/code]
希望本文所述对大家的Python程序设计有所帮助。