allow setting HistoryManager.hist_file with config #940

Merged
merged 2 commits into from Oct 30, 2011

2 participants

@minrk
IPython member

fixes trait init in HistoryAccessor, which prevented setting hist_file via config from having any effect.

Also remove dependency on having a shell object in HistoryAccessor.__init__

Associated test included.

as described in #882

@minrk minrk allow setting HistoryManager.hist_file with config
fixes improper init in HistoryAccessor, preventing setting `hist_file` via config from having any effect.

Also remove dependency on having a shell object in `HistoryAccessor.__init__`

Associated test included.
af429a3
@fperez fperez commented on an outdated diff Oct 29, 2011
IPython/core/tests/test_history.py
@@ -122,3 +125,10 @@ def test_timestamp_type():
ip = get_ipython()
info = ip.history_manager.get_session_info()
nt.assert_true(isinstance(info[1], datetime))
+
+def test_hist_file_config():
+ cfg = Config()
+ cfg.HistoryManager.hist_file = tempfile.mktemp()
@fperez
IPython member
fperez added a note Oct 29, 2011

mktemp is deprecated. For this particular test, I suggest instead creating the temp file with NamedTemporaryFile:

tfile = tempfile.NamedTemporaryFile(delete=False)
cfg.HistoryManager.hist_file = tfile.name
...

try:
  nt.assert...
finally:
  os.unlink(tfile.name)

That's the right pattern for these guys. In Pyhton 3 they've been turned into context managers, which is really what you want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@fperez
IPython member

Other than the above fixes to the test, the code looks good to me. I'll merge it once this small stuff is fixed; thanks!

@minrk
IPython member

suggested changes made and pushed

@fperez fperez merged commit 602e3c3 into ipython:master Oct 30, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment