By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,728 Members | 1,133 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,728 IT Pros & Developers. It's quick & easy.

Wierd Test Failure

P: n/a
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
Share this Question
Share on Google+
1 Reply

P: n/a
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.