[Tutor] question about lists and doctest

Roelof Wobben rwobben at hotmail.com
Thu Aug 26 17:41:25 CEST 2010


hello, 

 

I have this programm 

 

#  Add your doctests here:
"""
  >>> a_list[3]
  42
  >>> a_list[6]
  'Ni!'
  >>> len(a_list)
  8
"""
a_list = ['test', 'test','test',42,'test','test','Ni!','test']
print a_list[3]
print a_list[6]
print len(a_list)

if __name__ == '__main__':
    import doctest
    doctest.testmod()

 

If I change lets say 42 to 16 then the doctest fails with 

 

Expecting 

 

42 

 

Got 

 

16.

 

 

How does doctest now which values are right or not ?

 

Roelof

 

 

 
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100826/f151bb30/attachment.html>


More information about the Tutor mailing list