(
hmmax2, tmp_path, monkeypatch, caplog
)
| 322 | |
| 323 | |
| 324 | def 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 | |
| 353 | def test_histmanager_disabled(hmmax2): |
nothing calls this directly
no test coverage detected
searching dependent graphs…