##// END OF EJS Templates
This feature was discussed in #6123, but it doesn't look like anything was ever incorporated into the IPython Notebook....
This feature was discussed in #6123, but it doesn't look like anything was ever incorporated into the IPython Notebook. Here's a brief overview of the changes: - Display of messages from other clients can be toggled on and off from within a notebook, either using the ``<M-m>e`` keyboard shortcut in the web UI, or through the option in the "Kernel" menu. - notebook.js controls whether messages are displayed through a callback that is invoked from kernel.js when no callbacks are available for a message. - The UI displays ``execute_input`` messages originating from an other clients in new cells at the end of the notebook. Output messages (``execute_result`` et al.) will only be displayed if a cell exists with a matching message ID. Pending design questions: - Should each ``execute_input`` message cause a new cell to be created? - Should new cells be placed at the end of the notebook, or elsewhere? If the latter, what criteria should be followed?

File last commit:

r10135:eee3d3bf
r19164:17ac8ca3
Show More
doctestreload.py
80 lines | 2.8 KiB | text/x-python | PythonLexer
Brian Granger
Work to address the review comments on Fernando's branch....
r2498 # encoding: utf-8
"""
A utility for handling the reloading of doctest.
"""
#-----------------------------------------------------------------------------
Matthias BUSSONNIER
update copyright to 2011/20xx-2011...
r5390 # Copyright (C) 2008-2011 The IPython Development Team
Brian Granger
Work to address the review comments on Fernando's branch....
r2498 #
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
import sys
#-----------------------------------------------------------------------------
# Code
#-----------------------------------------------------------------------------
def dhook_wrap(func,*a,**k):
"""Wrap a function call in a sys.displayhook controller.
Returns a wrapper around func which calls func, with all its arguments and
keywords unmodified, using the default sys.displayhook. Since IPython
modifies sys.displayhook, it breaks the behavior of certain systems that
rely on the default behavior, notably doctest.
"""
def f(*a,**k):
dhook_s = sys.displayhook
sys.displayhook = sys.__displayhook__
try:
out = func(*a,**k)
finally:
sys.displayhook = dhook_s
return out
f.__doc__ = func.__doc__
return f
def doctest_reload():
"""Properly reload doctest to reuse it interactively.
This routine:
- imports doctest but does NOT reload it (see below).
- resets its global 'master' attribute to None, so that multiple uses of
Thomas Kluyver
Document need to call doctest_reload() with older Python versions
r10135 the module interactively don't produce cumulative reports.
Brian Granger
Work to address the review comments on Fernando's branch....
r2498
- Monkeypatches its core test runner method to protect it from IPython's
Thomas Kluyver
Document need to call doctest_reload() with older Python versions
r10135 modified displayhook. Doctest expects the default displayhook behavior
deep down, so our modification breaks it completely. For this reason, a
hard monkeypatch seems like a reasonable solution rather than asking
users to manually use a different doctest runner when under IPython.
Brian Granger
Work to address the review comments on Fernando's branch....
r2498
Notes
-----
Thomas Kluyver
Don't monkeypatch doctest during IPython startup....
r10134
As of Python 2.6.6, 2.7.1 and 3.2, this monkeypatching is no longer required.
doctest now takes care of resetting sys.displayhook itself. This function
remains for now in case anyone has to work with older versions, but it's
no longer called during IPython startup.
Brian Granger
Work to address the review comments on Fernando's branch....
r2498
This function *used to* reload doctest, but this has been disabled because
reloading doctest unconditionally can cause massive breakage of other
doctest-dependent modules already in memory, such as those for IPython's
own testing system. The name wasn't changed to avoid breaking people's
code, but the reload call isn't actually made anymore."""
import doctest
doctest.master = None
doctest.DocTestRunner.run = dhook_wrap(doctest.DocTestRunner.run)