Skip to content

Commit

Permalink
Merge pull request #7151 from ccordoba12/no-ipy-history-in-tests
Browse files Browse the repository at this point in the history
PR: Avoid loading/saving IPython console history in safe mode or testing
  • Loading branch information
ccordoba12 authored May 19, 2018
2 parents 9cf4574 + cf381a0 commit 0487c0a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 4 additions & 2 deletions spyder/utils/ipython/kernelspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

from jupyter_client.kernelspec import KernelSpec

from spyder.config.base import get_module_source_path
from spyder.config.base import (SAFE_MODE, get_module_source_path,
running_under_pytest)
from spyder.config.main import CONF
from spyder.utils.encoding import to_unicode_from_fs
from spyder.utils.programs import is_python_interpreter
Expand Down Expand Up @@ -128,7 +129,8 @@ def env(self):
'SPY_GREEDY_O': CONF.get('ipython_console', 'greedy_completer'),
'SPY_JEDI_O': CONF.get('ipython_console', 'jedi_completer'),
'SPY_SYMPY_O': CONF.get('ipython_console', 'symbolic_math'),
'SPY_RUN_CYTHON': self.is_cython
'SPY_RUN_CYTHON': self.is_cython,
'SPY_TESTING': running_under_pytest() or SAFE_MODE
}

# Add our PYTHONPATH to env_vars
Expand Down
10 changes: 7 additions & 3 deletions spyder/utils/ipython/start_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,17 @@ def kernel_config():
# ---- Spyder config ----
spy_cfg = Config()

# Enable/disable certain features for testing
testing = os.environ.get('SPY_TESTING') == 'True'
if testing:
# Don't load nor save history in our IPython consoles.
spy_cfg.HistoryAccessor.enabled = False

# Until we implement Issue 1052
spy_cfg.InteractiveShell.xmode = 'Plain'

# Jedi completer
# Jedi completer. It's only available in Python 3
jedi_o = os.environ.get('SPY_JEDI_O') == 'True'
# - Using Jedi slow completions a lot for objects with big repr's.
# - Jedi completions are not available in Python 2.
if not PY2:
spy_cfg.IPCompleter.use_jedi = jedi_o

Expand Down

0 comments on commit 0487c0a

Please sign in to comment.