???????????????python??????д???????????д?????е??????????????????????test.py????????У??????main??????????????????н????????????????????????????????????????????????顣?????????????Щ???????????????????????????????
??????????????????ò?????????????????????????????????PyUnit??????????飬??????漲????????????д?淶???????????????PyUnit???????????????????????????????PyUnit????????????????????£?????????python?????????
????1??pyunit????
????python2.1????汾??pyunit???python??????????飬???python????????????á?
???????????

 


PythonWin 2.7.2 (default?? Jun 12 2011?? 15:08:59) [MSC v.1500 32 bit (Intel)] on win32.
Portions Copyright 1994-2008 Mark Hammond - see 'Help/About PythonWin' for further copyright information.
>>> import unittest
>>>

????????2B?????v2????python?汾?????????дpyunit????????????
????2?? ???????????????????????????????????????????

# -*- coding:utf-8 -*-
import unittest
class Widget:
def __init__(self?? size = (40?? 40)):
self._size = size
def getSize(self):
return self._size
def resize(self?? width?? height):
if width < 0 or height < 0:
raise ValueError?? "illegal size"
self._size = (width?? height)
def dispose(self):
pass
class WidgetTestCase(unittest.TestCase):
def setUp(self):
self.widget = Widget()
def tearDown(self):
self.widget = None
def testSize(self):
self.assertEqual(self.widget.getSize()?? (40?? 40))
def suite():
suite = unittest.TestSuite()
suite.addTest(WidgetTestCase("testSize"))
return suite
if __name__ == "__main__":
unittest.main(defaultTest = 'suite')
??н??(pythonWin????н??)??
>>> .
----------------------------------------------------------------------
Ran 1 test in 0.000s
OK
???????????????????????????????????Widget.getSize()??????????????????????????????????????????????