diff --git a/IPython/core/tests/test_history.py b/IPython/core/tests/test_history.py index 5474da9..95a25f3 100644 --- a/IPython/core/tests/test_history.py +++ b/IPython/core/tests/test_history.py @@ -61,7 +61,10 @@ def test_history(): # New session ip.history_manager.reset() - newcmds = ["z=5","class X(object):\n pass", "k='p'"] + newcmds = [u"z=5", + u"class X(object):\n pass", + u"k='p'", + u"z=5"] for i, cmd in enumerate(newcmds, start=1): ip.history_manager.store_inputs(i, cmd) gothist = ip.history_manager.get_range(start=1, stop=4) @@ -70,18 +73,17 @@ def test_history(): gothist = ip.history_manager.get_range(-1, 1, 4) nt.assert_equal(list(gothist), zip([1,1,1],[1,2,3], hist)) + newhist = [(2, i + 1, c) for (i, c) in enumerate(newcmds)] + # Check get_hist_tail - gothist = ip.history_manager.get_tail(4, output=True, + gothist = ip.history_manager.get_tail(5, output=True, include_latest=True) - expected = [(1, 3, (hist[-1], "spam")), - (2, 1, (newcmds[0], None)), - (2, 2, (newcmds[1], None)), - (2, 3, (newcmds[2], None)),] + expected = [(1, 3, (hist[-1], "spam"))] \ + + [(s, n, (c, None)) for (s, n, c) in newhist] nt.assert_equal(list(gothist), expected) gothist = ip.history_manager.get_tail(2) - expected = [(2, 1, newcmds[0]), - (2, 2, newcmds[1])] + expected = newhist[-3:-1] nt.assert_equal(list(gothist), expected) # Check get_hist_search @@ -92,13 +94,15 @@ def test_history(): [(1, 1, hist[0]), (1, 2, hist[1]), (1, 3, hist[2]), - (2, 1, newcmds[0]), - (2, 3, newcmds[2])]) - gothist = ip.history_manager.search("*=*", n=3) + newhist[0], + newhist[2], + newhist[3]]) + gothist = ip.history_manager.search("*=*", n=4) nt.assert_equal(list(gothist), [(1, 3, hist[2]), - (2, 1, newcmds[0]), - (2, 3, newcmds[2])]) + newhist[0], + newhist[2], + newhist[3]]) gothist = ip.history_manager.search("b*", output=True) nt.assert_equal(list(gothist), [(1,3,(hist[2],"spam"))] )