Message72124
Here's an example from a python interpreter session:
Python 2.4.4 (#71, Oct 18 2006, 08:34:43) [MSC v.1310 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> def test():
... print "hello"
... raise Exception()
...
>>> test()
hello
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "<stdin>", line 3, in test
Exception
Now, turning this into a doctests gives:
"""
>>> def test():
... print "hello"
... raise Exception()
...
>>> test()
hello
Traceback (most recent call last):
...
Exception
"""
Which when run gives:
**********************************************************************
File "C:\Projects\doctestbug.py", line 6, in __main__
Failed example:
test()
Exception raised:
Traceback (most recent call last):
File "C:\Python25\lib\doctest.py", line 1212, in __run
compileflags, 1) in test.globs
File "<doctest __main__[1]>", line 1, in <module>
test()
File "<doctest __main__[0]>", line 3, in test
raise Exception()
Exception
**********************************************************************
1 items had failures:
1 of 2 in __main__
***Test Failed*** 1 failures.
The problem is that the function prints output before raising the
exception. If I take the printed output away, the doctest passes fine.
However, especially with dummy fixtures common in doctests, that printed
output needs to be seen to test that things are happening as they should
prior to the exception being raised. |
|
Date |
User |
Action |
Args |
2008-08-29 10:54:13 | cjw296 | set | recipients:
+ cjw296 |
2008-08-29 10:54:13 | cjw296 | set | messageid: <1220007253.68.0.614144600028.issue3722@psf.upfronthosting.co.za> |
2008-08-29 10:54:12 | cjw296 | link | issue3722 messages |
2008-08-29 10:54:11 | cjw296 | create | |
|