Show More
@@ -61,7 +61,10 b' def test_history():' | |||||
61 |
|
61 | |||
62 | # New session |
|
62 | # New session | |
63 | ip.history_manager.reset() |
|
63 | ip.history_manager.reset() | |
64 | newcmds = ["z=5","class X(object):\n pass", "k='p'"] |
|
64 | newcmds = [u"z=5", | |
|
65 | u"class X(object):\n pass", | |||
|
66 | u"k='p'", | |||
|
67 | u"z=5"] | |||
65 | for i, cmd in enumerate(newcmds, start=1): |
|
68 | for i, cmd in enumerate(newcmds, start=1): | |
66 | ip.history_manager.store_inputs(i, cmd) |
|
69 | ip.history_manager.store_inputs(i, cmd) | |
67 | gothist = ip.history_manager.get_range(start=1, stop=4) |
|
70 | gothist = ip.history_manager.get_range(start=1, stop=4) | |
@@ -70,18 +73,17 b' def test_history():' | |||||
70 | gothist = ip.history_manager.get_range(-1, 1, 4) |
|
73 | gothist = ip.history_manager.get_range(-1, 1, 4) | |
71 | nt.assert_equal(list(gothist), zip([1,1,1],[1,2,3], hist)) |
|
74 | nt.assert_equal(list(gothist), zip([1,1,1],[1,2,3], hist)) | |
72 |
|
75 | |||
|
76 | newhist = [(2, i + 1, c) for (i, c) in enumerate(newcmds)] | |||
|
77 | ||||
73 | # Check get_hist_tail |
|
78 | # Check get_hist_tail | |
74 |
gothist = ip.history_manager.get_tail( |
|
79 | gothist = ip.history_manager.get_tail(5, output=True, | |
75 | include_latest=True) |
|
80 | include_latest=True) | |
76 |
expected = [(1, 3, (hist[-1], "spam")) |
|
81 | expected = [(1, 3, (hist[-1], "spam"))] \ | |
77 | (2, 1, (newcmds[0], None)), |
|
82 | + [(s, n, (c, None)) for (s, n, c) in newhist] | |
78 | (2, 2, (newcmds[1], None)), |
|
|||
79 | (2, 3, (newcmds[2], None)),] |
|
|||
80 | nt.assert_equal(list(gothist), expected) |
|
83 | nt.assert_equal(list(gothist), expected) | |
81 |
|
84 | |||
82 | gothist = ip.history_manager.get_tail(2) |
|
85 | gothist = ip.history_manager.get_tail(2) | |
83 |
expected = [ |
|
86 | expected = newhist[-3:-1] | |
84 | (2, 2, newcmds[1])] |
|
|||
85 | nt.assert_equal(list(gothist), expected) |
|
87 | nt.assert_equal(list(gothist), expected) | |
86 |
|
88 | |||
87 | # Check get_hist_search |
|
89 | # Check get_hist_search | |
@@ -92,13 +94,15 b' def test_history():' | |||||
92 | [(1, 1, hist[0]), |
|
94 | [(1, 1, hist[0]), | |
93 | (1, 2, hist[1]), |
|
95 | (1, 2, hist[1]), | |
94 | (1, 3, hist[2]), |
|
96 | (1, 3, hist[2]), | |
95 |
|
|
97 | newhist[0], | |
96 |
|
|
98 | newhist[2], | |
97 | gothist = ip.history_manager.search("*=*", n=3) |
|
99 | newhist[3]]) | |
|
100 | gothist = ip.history_manager.search("*=*", n=4) | |||
98 | nt.assert_equal(list(gothist), |
|
101 | nt.assert_equal(list(gothist), | |
99 | [(1, 3, hist[2]), |
|
102 | [(1, 3, hist[2]), | |
100 |
|
|
103 | newhist[0], | |
101 |
|
|
104 | newhist[2], | |
|
105 | newhist[3]]) | |||
102 | gothist = ip.history_manager.search("b*", output=True) |
|
106 | gothist = ip.history_manager.search("b*", output=True) | |
103 | nt.assert_equal(list(gothist), [(1,3,(hist[2],"spam"))] ) |
|
107 | nt.assert_equal(list(gothist), [(1,3,(hist[2],"spam"))] ) | |
104 |
|
108 |
General Comments 0
You need to be logged in to leave comments.
Login now