diff --git a/core/doc/helper.rst b/core/doc/helper.rst index c790f0ab5a8f3c4465f858bcbbd89c5264035444..3108fb5c90323978cba701325291b749931906f5 100644 --- a/core/doc/helper.rst +++ b/core/doc/helper.rst @@ -26,6 +26,11 @@ Messages else: raise +.. testoutput:: helper + :hide: + + Something failed! + .. doctest:: helper from promod3.core import helper diff --git a/doc/conf.py.in b/doc/conf.py.in index 1cc6b9e8be37f81e1c1a964d2304cc44881b9efa..72f2d4b89c3861c15c0c354e884282dc774c08fa 100644 --- a/doc/conf.py.in +++ b/doc/conf.py.in @@ -283,6 +283,23 @@ doctest_global_setup = """ import sys sys.path.insert(0, '@LIB_STAGE_PATH@/python@PYTHON_VERSION@/site-packages') sys.path.insert(1, '@OST_ROOT@/@LIB_DIR@/python@PYTHON_VERSION@/site-packages') + +import ost + +# We define a LogSink here, pushing everything to stdout so doctest recognises +# it. +class DocTestLogger(ost.LogSink): + def __init__(self): + ost.LogSink.__init__(self) + + def LogMessage(self, message, severity): + levels = ['ERROR', 'WARNING', 'SCRIPT', 'INFO', 'VERBOSE', 'DEBUG', + 'TRACE'] + level = levels[severity] + print '%s' % (message), + +doctest_logger = DocTestLogger() +ost.PushLogSink(doctest_logger) """ # LocalWords: cmake