From 2d66a78ba26ba2644d0d0b9da8941dfdab9f6f64 2009-04-23 22:24:48 From: Fernando Perez Date: 2009-04-23 22:24:48 Subject: [PATCH] Make default argv for testing instances. This simple utility lets us ensure that all testing instances of ipython can be consistently initialized in an identical manner. --- diff --git a/IPython/testing/plugin/ipdoctest.py b/IPython/testing/plugin/ipdoctest.py index 617de83..d3ad3d2 100644 --- a/IPython/testing/plugin/ipdoctest.py +++ b/IPython/testing/plugin/ipdoctest.py @@ -59,6 +59,19 @@ log = logging.getLogger(__name__) # machinery into a fit. This code should be considered a gross hack, but it # gets the job done. +def default_argv(): + """Return a valid default argv for creating testing instances of ipython""" + + # Get the install directory for the user configuration and tell ipython to + # use the default profile from there. + from IPython import UserConfig + ipcdir = os.path.dirname(UserConfig.__file__) + #ipconf = os.path.join(ipcdir,'ipy_user_conf.py') + ipconf = os.path.join(ipcdir,'ipythonrc') + #print 'conf:',ipconf # dbg + + return ['--colors=NoColor','--noterm_title','-rcfile=%s' % ipconf] + # Hack to modify the %run command so we can sync the user's namespace with the # test globals. Once we move over to a clean magic system, this will be done @@ -148,10 +161,11 @@ def start_ipython(): _excepthook = sys.excepthook _main = sys.modules.get('__main__') + argv = default_argv() + # Start IPython instance. We customize it to start with minimal frills. user_ns,global_ns = IPython.ipapi.make_user_namespaces(ipnsdict(),dict()) - IPython.Shell.IPShell(['--colors=NoColor','--noterm_title'], - user_ns,global_ns) + IPython.Shell.IPShell(argv,user_ns,global_ns) # Deactivate the various python system hooks added by ipython for # interactive convenience so we don't confuse the doctest system