Show More
@@ -30,11 +30,11 b' def test_history():' | |||||
30 | ip.history_manager = HistoryManager(ip) |
|
30 | ip.history_manager = HistoryManager(ip) | |
31 | ip.history_manager.hist_file = histfile |
|
31 | ip.history_manager.hist_file = histfile | |
32 | print 'test',histfile |
|
32 | print 'test',histfile | |
33 |
hist = ['a=1 |
|
33 | hist = ['a=1', 'def f():\n test = 1\n return test', 'b=2'] | |
34 | # test save and load |
|
34 | # test save and load | |
35 | ip.history_manager.input_hist_raw[:] = [] |
|
35 | ip.history_manager.input_hist_raw[:] = [] | |
36 | for h in hist: |
|
36 | for h in hist: | |
37 |
ip.history_manager.input |
|
37 | ip.history_manager.store_inputs(h) | |
38 | ip.save_history() |
|
38 | ip.save_history() | |
39 | ip.history_manager.input_hist_raw[:] = [] |
|
39 | ip.history_manager.input_hist_raw[:] = [] | |
40 | ip.reload_history() |
|
40 | ip.reload_history() | |
@@ -43,6 +43,23 b' def test_history():' | |||||
43 | nt.assert_equal(len(ip.history_manager.input_hist_raw), len(hist)) |
|
43 | nt.assert_equal(len(ip.history_manager.input_hist_raw), len(hist)) | |
44 | for i,h in enumerate(hist): |
|
44 | for i,h in enumerate(hist): | |
45 | nt.assert_equal(hist[i], ip.history_manager.input_hist_raw[i]) |
|
45 | nt.assert_equal(hist[i], ip.history_manager.input_hist_raw[i]) | |
|
46 | ||||
|
47 | # Test that session offset works. | |||
|
48 | ip.history_manager.session_offset = \ | |||
|
49 | len(ip.history_manager.input_hist_raw) -1 | |||
|
50 | newcmds = ["z=5","class X(object):\n pass", "k='p'"] | |||
|
51 | for cmd in newcmds: | |||
|
52 | ip.history_manager.store_inputs(cmd) | |||
|
53 | gothist = ip.history_manager.get_history((1,4), | |||
|
54 | raw=True, output=False) | |||
|
55 | nt.assert_equal(gothist, dict(zip([1,2,3], newcmds))) | |||
|
56 | ||||
|
57 | # Cross testing: check that magic %save picks up on the session | |||
|
58 | # offset. | |||
|
59 | testfilename = os.path.realpath(os.path.join(tmpdir, "test.py")) | |||
|
60 | ip.magic_save(testfilename + " 1-3") | |||
|
61 | testfile = open(testfilename, "r") | |||
|
62 | nt.assert_equal(testfile.read(), "\n".join(newcmds)) | |||
46 | finally: |
|
63 | finally: | |
47 | # Restore history manager |
|
64 | # Restore history manager | |
48 | ip.history_manager = hist_manager_ori |
|
65 | ip.history_manager = hist_manager_ori |
General Comments 0
You need to be logged in to leave comments.
Login now