--- /usr/lib/python2.6/doctest.py 2009-12-07 21:30:15.000000000 +0200 +++ /home/noam/lib/python/doctest.py 2010-03-03 10:05:05.000000000 +0200 @@ -1325,6 +1325,11 @@ else: return self.save_linecache_getlines(filename, module_globals) + def _displayhook(self, obj): + if obj is not None: + sys.stdout.write(repr(obj)) + sys.stdout.write('\n') + def run(self, test, compileflags=None, out=None, clear_globs=True): """ Run the examples in `test`, and display the results using the @@ -1370,12 +1375,17 @@ self.save_linecache_getlines = linecache.getlines linecache.getlines = self.__patched_linecache_getlines + # Make sure sys.displayhook just prints the value to stdout + save_displayhook = sys.displayhook + sys.displayhook = self._displayhook + try: return self.__run(test, compileflags, out) finally: sys.stdout = save_stdout pdb.set_trace = save_set_trace linecache.getlines = self.save_linecache_getlines + sys.displayhook = save_displayhook if clear_globs: test.globs.clear()