[Tutor] question about lists and doctest

Nitin Das nitin.162 at gmail.com
Thu Aug 26 18:40:08 CEST 2010


The doctest module searches for pieces of text that look like interactive
Python sessions, and then executes those sessions to verify that they work
exactly as shown.
Here ur a_list[3] in docstring is 42 then doctest expects it to be 42 for
success. Since u changed 42 to 16 then it is not = 42 as per the
a_list[3]=42 in docstring hence it raises error.

--nitin

On Thu, Aug 26, 2010 at 9:11 PM, Roelof Wobben <rwobben at hotmail.com> wrote:

>  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
>
>
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100826/9f6a4421/attachment.html>


More information about the Tutor mailing list