Python????????---Pyunit????
???????????? ???????[ 2013/12/5 11:41:37 ] ????????
???????????????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
|
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11