Show More
@@ -23,10 +23,10 b' def setUp():' | |||||
23 | def test_history(): |
|
23 | def test_history(): | |
24 | ip = get_ipython() |
|
24 | ip = get_ipython() | |
25 | with TemporaryDirectory() as tmpdir: |
|
25 | with TemporaryDirectory() as tmpdir: | |
26 | # Make a new :memory: DB. |
|
|||
27 | hist_manager_ori = ip.history_manager |
|
26 | hist_manager_ori = ip.history_manager | |
|
27 | hist_file = os.path.join(tmpdir, 'history.sqlite') | |||
28 | try: |
|
28 | try: | |
29 |
ip.history_manager = HistoryManager(shell=ip, hist_file= |
|
29 | ip.history_manager = HistoryManager(shell=ip, hist_file=hist_file) | |
30 | hist = ['a=1', 'def f():\n test = 1\n return test', u"b='€Æ¾÷ß'"] |
|
30 | hist = ['a=1', 'def f():\n test = 1\n return test', u"b='€Æ¾÷ß'"] | |
31 | for i, h in enumerate(hist, start=1): |
|
31 | for i, h in enumerate(hist, start=1): | |
32 | ip.history_manager.store_inputs(i, h) |
|
32 | ip.history_manager.store_inputs(i, h) | |
@@ -38,10 +38,7 b' def test_history():' | |||||
38 |
|
38 | |||
39 | nt.assert_equal(ip.history_manager.input_hist_raw, [''] + hist) |
|
39 | nt.assert_equal(ip.history_manager.input_hist_raw, [''] + hist) | |
40 |
|
40 | |||
41 | # Check lines were written to DB |
|
41 | ||
42 | c = ip.history_manager.db.execute("SELECT source_raw FROM history") |
|
|||
43 | nt.assert_equal([x for x, in c], hist) |
|
|||
44 |
|
||||
45 | # New session |
|
42 | # New session | |
46 | ip.history_manager.reset() |
|
43 | ip.history_manager.reset() | |
47 | newcmds = ["z=5","class X(object):\n pass", "k='p'"] |
|
44 | newcmds = ["z=5","class X(object):\n pass", "k='p'"] | |
@@ -83,6 +80,7 b' def test_history():' | |||||
83 | # Duplicate line numbers - check that it doesn't crash, and |
|
80 | # Duplicate line numbers - check that it doesn't crash, and | |
84 | # gets a new session |
|
81 | # gets a new session | |
85 | ip.history_manager.store_inputs(1, "rogue") |
|
82 | ip.history_manager.store_inputs(1, "rogue") | |
|
83 | ip.history_manager.writeout_cache() | |||
86 | nt.assert_equal(ip.history_manager.session_number, 3) |
|
84 | nt.assert_equal(ip.history_manager.session_number, 3) | |
87 | finally: |
|
85 | finally: | |
88 | # Restore history manager |
|
86 | # Restore history manager |
General Comments 0
You need to be logged in to leave comments.
Login now