##// END OF EJS Templates
Merge pull request #1155 from minrk/postexec...
Merge pull request #1155 from minrk/postexec Be less aggressive in de-registering failing post-execute functions so that normal errors don't disable them permanently. Two changes: 1. Don't unregister failing post-exec callbacks automatically. Instead, print a message regarding the failure, pointing to new `disable_failing_post_execute` trait for skipping failing callbacks. - When this flag is False (the default), failing callbacks will continue to be called. - When True, behavior is unchanged from previous, where callbacks are only allowed to fail once. 2. protect `flush_figures()` post-exec function from user error. Invalid matplotlib data may raise inside `print_figure()`. flush_figures() is a post-exec function, so user errors should not raise. Instead, call `get_ipython().showtraceback()` if called from IPython, raising as before otherwise. closes #1154

File last commit:

r2267:928c921b
r5737:2c683b72 merge
Show More
ipy_profile_doctest.py
46 lines | 1.5 KiB | text/x-python | PythonLexer
"""Config file for 'doctest' profile.
This profile modifies the prompts to be the standard Python ones, so that you
can generate easily doctests from an IPython session.
But more importantly, it enables pasting of code with '>>>' prompts and
arbitrary initial whitespace, as is typical of doctests in reST files and
docstrings. This allows you to easily re-run existing doctests and iteratively
work on them as part of your development workflow.
The exception mode is also set to 'plain' so the generated exceptions are as
similar as possible to the default Python ones, for inclusion in doctests."""
# get various stuff that are there for historical / familiarity reasons
import ipy_legacy
from IPython.core import ipapi
from IPython.extensions import InterpreterPasteInput
def main():
ip = ipapi.get()
o = ip.options
# Set the prompts similar to the defaults
o.prompt_in1 = '>>> '
o.prompt_in2 = '... '
o.prompt_out = ''
# Add a blank line before each new set of inputs. This is needed by
# doctest to distinguish each test from the next.
o.separate_in = '\n'
o.separate_out = ''
o.separate_out2 = ''
# Disable pprint, so that outputs are printed as similarly to standard
# python as possible
o.pprint = False
# Use plain exceptions, to also resemble normal pyhton.
o.xmode = 'plain'
# Store the activity flag in the metadata bag from the running shell
ip.meta.doctest_mode = True
main()