(hmmax3, tmp_path, caplog)
| 285 | |
| 286 | |
| 287 | def test_histmanager_memory_fallback_reopens_db(hmmax3, tmp_path, caplog): |
| 288 | hist_file = tmp_path / "history.sqlite" |
| 289 | ip = get_ipython() |
| 290 | hm1 = None |
| 291 | hm2 = None |
| 292 | lock = None |
| 293 | try: |
| 294 | hm1 = HistoryManager(shell=ip, hist_file=hist_file) |
| 295 | hm1.end_session() |
| 296 | hm1.save_thread.stop() |
| 297 | hm1.db.close() |
| 298 | |
| 299 | lock = sqlite3.connect(hist_file) |
| 300 | lock.execute("BEGIN IMMEDIATE") |
| 301 | |
| 302 | hm2 = HistoryManager(shell=ip, hist_file=hist_file) |
| 303 | assert hm2.hist_file == ":memory:" |
| 304 | assert hm2.db.execute("PRAGMA database_list").fetchall() == [(0, "main", "")] |
| 305 | |
| 306 | hm2.store_inputs(1, "a = 1") |
| 307 | hm2.writeout_cache() |
| 308 | assert list(hm2.get_tail(1, include_latest=True)) == [ |
| 309 | (hm2.session_number, 1, "a = 1") |
| 310 | ] |
| 311 | finally: |
| 312 | if hm2 is not None: |
| 313 | hm2.end_session() |
| 314 | hm2.db.close() |
| 315 | if lock is not None: |
| 316 | lock.rollback() |
| 317 | lock.close() |
| 318 | hm1 = None |
| 319 | hm2 = None |
| 320 | caplog.clear() |
| 321 | gc.collect() |
| 322 | |
| 323 | |
| 324 | def test_histmanager_thread_start_failure_uses_memory( |
nothing calls this directly
no test coverage detected
searching dependent graphs…