def load_config_file(self, *args, **kwds): r""" Merges a config file with the default sage config. .. note:: This code is based on :meth:`Application.update_config`. TESTS: Test that :trac:`15972` has been fixed:: sage: from sage.misc.temporary_file import tmp_dir sage: from sage.repl.interpreter import SageTerminalApp sage: d = tmp_dir() sage: from IPython.paths import get_ipython_dir sage: IPYTHONDIR = get_ipython_dir() sage: os.environ['IPYTHONDIR'] = d sage: SageTerminalApp().load_config_file() sage: os.environ['IPYTHONDIR'] = IPYTHONDIR """ super(SageTerminalApp, self).load_config_file(*args, **kwds) newconfig = sage_ipython_config.default() # merge in the config loaded from file newconfig.merge(self.config) self.config = newconfig
def get_test_shell(): """ Returns a IPython shell that can be used in testing the functions in this module. OUTPUT: An IPython shell EXAMPLES:: sage: from sage.repl.interpreter import get_test_shell sage: shell = get_test_shell(); shell <sage.repl.interpreter.SageTestShell object at 0x...> sage: shell.parent.shell_class <class 'sage.repl.interpreter.SageTestShell'> sage: shell.parent.test_shell True sage: shell.quit() TESTS: Check that :trac:`14070` has been resolved:: sage: from sage.tests.cmdline import test_executable sage: cmd = 'from sage.repl.interpreter import get_test_shell; shell = get_test_shell()' sage: (out, err, ret) = test_executable(["sage", "-c", cmd]) sage: out + err '' """ config = sage_ipython_config.default() config.TerminalIPythonApp.test_shell = True config.TerminalIPythonApp.shell_class = SageTestShell app = SageTerminalApp.instance(config=config) if app.shell is None: app.initialize(argv=[]) else: try: app.shell._restart() except AttributeError: pass # No quit noise app.shell.verbose_quit = False return app.shell