From 9c3facfe7e1838739a54d82cfc21c0d3f5f24e14 Mon Sep 17 00:00:00 2001 From: BoulderBadgeDad Date: Wed, 17 Jun 2026 11:44:21 -0700 Subject: [PATCH] Enricher: don't spawn the background daemon under pytest (test isolation) The enrichment daemon was starting during API tests (it uses the default DB + network), touching a stray real DB and causing sqlite disk-IO flakiness. enqueue() now no-ops when PYTEST_CURRENT_TEST is set; _enrich() is still tested directly with a tmp DB. 176 video tests green. --- core/video/youtube_enrichment.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/video/youtube_enrichment.py b/core/video/youtube_enrichment.py index af7e6431..ec07ad77 100644 --- a/core/video/youtube_enrichment.py +++ b/core/video/youtube_enrichment.py @@ -13,6 +13,7 @@ followed (or its page opened while followed). Reads/writes only video_library.db from __future__ import annotations +import os import queue import threading import time @@ -50,6 +51,10 @@ class YoutubeDateEnricher: cid = str(channel_id or "").strip() if not cid: return + # Never spawn the background daemon (network + the default DB) under tests; + # the enricher's logic is exercised directly via _enrich() with a tmp DB. + if os.environ.get("PYTEST_CURRENT_TEST"): + return with self._lock: if title: self._titles[cid] = title