MCPcopy Index your code
hub / github.com/ipython/ipython / test_histmanager_thread_start_failure_uses_memory

Function test_histmanager_thread_start_failure_uses_memory

tests/test_history.py:324–350  ·  view source on GitHub ↗
(
    hmmax2, tmp_path, monkeypatch, caplog
)

Source from the content-addressed store, hash-verified

322
323
324def test_histmanager_thread_start_failure_uses_memory(
325 hmmax2, tmp_path, monkeypatch, caplog
326):
327 def fail_start(self):
328 raise RuntimeError("thread unavailable")
329
330 monkeypatch.setattr("IPython.core.history.HistorySavingThread.start", fail_start)
331
332 hm = None
333 try:
334 hm = HistoryManager(shell=get_ipython(), hist_file=tmp_path / "history.sqlite")
335 assert hm.hist_file == ":memory:"
336 assert hm.db.execute("PRAGMA database_list").fetchall() == [(0, "main", "")]
337 assert hm.save_thread is None
338
339 hm.store_inputs(1, "a = 1")
340 hm.writeout_cache()
341 assert list(hm.get_tail(1, include_latest=True)) == [
342 (hm.session_number, 1, "a = 1")
343 ]
344 finally:
345 if hm is not None:
346 hm.end_session()
347 hm.db.close()
348 hm = None
349 caplog.clear()
350 gc.collect()
351
352
353def test_histmanager_disabled(hmmax2):

Callers

nothing calls this directly

Calls 9

store_inputsMethod · 0.95
writeout_cacheMethod · 0.95
get_tailMethod · 0.95
end_sessionMethod · 0.95
HistoryManagerClass · 0.90
executeMethod · 0.80
get_ipythonFunction · 0.70
closeMethod · 0.45
collectMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…