469,955 Members | 2,544 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,955 developers. It's quick & easy.

Wierd Test Failure

Hello. Im using doctests to check the functions that ive made. Wat i
dnt understand is that it gives me a fialure even though the expected
and got values are the same. Check this out:

************************************************** ********************
File "C:\Python25\Lib\idlelib\idle.pyw", line ?, in
__main__.Test.test8
Failed example:
Test.test8()
Expected:
True
Got:
True
************************************************** ********************

If both the values are returning True how is it possible for the test
to fail? :S
Jun 27 '08 #1
1 906
J-Burns wrote:
Hello. Im using doctests to check the functions that ive made. Wat i
dnt understand is that it gives me a fialure even though the expected
and got values are the same. Check this out:

************************************************** ********************
File "C:\Python25\Lib\idlelib\idle.pyw", line ?, in
__main__.Test.test8
Failed example:
Test.test8()
Expected:
True
Got:
True
************************************************** ********************

If both the values are returning True how is it possible for the test
to fail? :S
Here's one way:

$ cat tmp.py
"""
>>print " \bTrue"
True
"""
import doctest
doctest.testmod()
$ python tmp.py
************************************************** ********************
File "tmp.py", line 2, in __main__
Failed example:
print "True"
Expected:
True
Got:
True
************************************************** ********************
1 items had failures:
1 of 1 in __main__
***Test Failed*** 1 failures.

" \bTrue" and "True" look the same but won't pass the equality test
performed by doctest.

As a side note, consider putting your own code in a separate file outside
the python distribution. Otherwise you risk messing up python and producing
more "weird" errors.

Peter
Jun 27 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Kevin Parkes | last post: by
6 posts views Thread by Qun Cao | last post: by
2 posts views Thread by CMEDIA_SOUND | last post: by
1 post views Thread by cody | last post: by
4 posts views Thread by Muthu Arumugam | last post: by
176 posts views Thread by nw | last post: by
1 post views Thread by Cirene | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.