??????????????ù???
????1??????????????????????С????????????????????????
????2???????????????????????????????????????С???????ζ???????????????????????????????????????Щ???????????????setUp()??setDown()?????????
????3????д??п?????????????Щ????£????????????????????????????????е????????????????????????л????????????????????£?????????????????????????????С?
????4?????ò??????????????????????
????5?????д?????????????????????????д????????????????Ρ????????????????д???????????κ????飻
????6????????????????????????
????7???????????????????????д??????????????????????????????????????????????????????????????????????????
????8??????????????ó????????????????????????????д????У????????square()??sqr()??????????????????У?????????test_square_of_number_2()??test_square_negativer_number()??Щ???????Щ?????????????????
????9??????????????п?????
????10?????????????????????????????????
???????????????????
????2.1 Unittest
????unittest??Python??????????????API??Java??JUnit??.net??NUnit??C++??CppUnit???????
??????????unittest.TestCase???????????????????
??????????ο??????
???????????
????import unittest
????def fun(x):
????return x + 1
????class MyTest(unittest.TestCase):
????def test(self):
????self.assertEqual(fun(3)?? 4)
??????к?????
?????????????????????????5??????е?????????????

????2.2 Doctest
????doctest ??????????Щ??????????????? Python ??????Σ????????в???????.??????????? doctest????????????????????п??????????“??????????????????????????docstring?????” ???????????????????????????
????????????
????def square(x):
????"""Squares x.
????>>> square(2)
????4
????>>> square(-2)
????4
????>>> square(5)
????25
????"""
????return x * x
????if __name__ == '__main__':
????import doctest
????doctest.testmod()
????????и???????????????>>> ???????????????????е??????б?????е??????£?

???????????????????????£?square(2)???????5????????????£?
????def square(x):
????"""Squares x.
????>>> square(2)
????5
????>>> square(-2)
????4
????>>> square(5)
????25
????"""
????return x * x
????if __name__ == '__main__':
????import doctest
????doctest.testmod()
??????е???????????????

 ????2.3 py.test
????py.test??unittest??????????
????????????????????????????????????????????????????????????????д??????????????unittest?????????????????py.test????????????