doctests behave differently inside dreampie

Bug #530969 reported by MikeyB
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
DreamPie
Triaged
Undecided
Unassigned

Bug Description

Dreampie 1.0
Python sys.version_info: (2, 6, 2, 'final', 0)

Running the following code:
def demofunction(a, b):
    '''Simple demonstration function

    >>> demofunction(3, 4)
    7
    '''
    return a+b

import doctest
doctest.testmod()

results in:
Dreampie:
>>> doctest.testmod()
**********************************************************************
File "__main__", line 4, in __main__.demofunction
Failed example:
    demofunction(3, 4)
Expected:
    7
Got nothing
**********************************************************************
1 items had failures:
   1 of 1 in __main__.demofunction
***Test Failed*** 2 failures.
8: TestResults(failed=1, attempted=1)

Python shell:
>>> doctest.testmod()
TestResults(failed=0, attempted=1)

Tags: doctest
Revision history for this message
Noam Yorav-Raphael (noamraph) wrote :

Thanks for the report!

It turns out that the problem is that doctest assumes that sys.displayhook just prints the value it gets into stdout, while DreamPie installs a different displayhook.

I filed a bug at http://bugs.python.org/issue8048 . In the meanwhile, you can replace your doctest.py file with the attached file, which fixes this bug.

Revision history for this message
Noam Yorav-Raphael (noamraph) wrote :
Changed in dreampie:
status: New → Triaged
Revision history for this message
MikeyB (supermathie) wrote :

Much better, thanks!

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.