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

Function test_calling_run_cell

tests/test_history.py:456–479  ·  view source on GitHub ↗
(hmmax2)

Source from the content-addressed store, hash-verified

454
455
456def test_calling_run_cell(hmmax2):
457 ip = get_ipython()
458 with TemporaryDirectory() as tmpdir:
459 tmp_path = Path(tmpdir)
460 hist_manager_ori = ip.history_manager
461 hist_file = tmp_path / "history_test_history1.sqlite"
462 try:
463 ip.history_manager = HistoryManager(shell=ip, hist_file=hist_file)
464 import time
465
466 session_number = ip.history_manager.session_number
467 ip.run_cell(raw_cell="get_ipython().run_cell(raw_cell='1', store_history=True)", store_history=True)
468 while ip.history_manager.db_input_cache:
469 time.sleep(0)
470 new_session_number = ip.history_manager.session_number
471 finally:
472 # Ensure saving thread is shut down before we try to clean up the files
473 ip.history_manager.end_session()
474 # Forcibly close database rather than relying on garbage collection
475 ip.history_manager.save_thread.stop()
476 ip.history_manager.db.close()
477
478 ip.history_manager = hist_manager_ori
479 assert session_number == new_session_number, ValueError(f"{session_number} != {new_session_number}")
480
481
482def _make_history_db(hist_file: Path, n_entries: int) -> None:

Callers

nothing calls this directly

Calls 6

HistoryManagerClass · 0.90
end_sessionMethod · 0.80
stopMethod · 0.80
get_ipythonFunction · 0.70
run_cellMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…