????python?е?????????????doctest??unittest???
????1.doctest?????
????(1)д?????????(cubetest.py)??

 

#!/usr/bin/python
def cube(x):
"""
cube a number and return the result
>>> cube(2)
8
>>> cube(3)
27
>>> cube(4)
64
"""
return x**3;
if __name__=='__main__':
import doctest;
doctest.testmod(verbose=True);

????????????д???????””” cube a number… “””?С?
????????doctest?е?testmod?????????????
??????????£?

Trying:
cube(2)
Expecting:
8
ok
Trying:
cube(3)
Expecting:
27
ok
Trying:
cube(4)
Expecting:
64
ok
1 itemshad no tests:
__main__
1 itemspassed all tests:
3 tests in __main__.cube
3 testsin 2 items.
3 passedand 0 failed.
Testpassed.
TestResults(failed=0?? attempted=3)
 
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????