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.
This commit is contained in:
parent
217486b3c7
commit
9c3facfe7e
1 changed files with 5 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue