Multi-instance failover, exponential-backoff retry, SQLite cache, batch mode, domain filter, cross-engine dedup, result sorting, CSV export, structured logging, enhanced Markdown conversion, 155 pytest tests, Gitea Actions CI
29 lines
979 B
Python
29 lines
979 B
Python
"""Shared fixtures and path setup for the searxng-cli test suite.
|
|
|
|
This conftest is loaded by pytest before any test module is imported, so
|
|
the ``sys.path`` insertion below makes the scripts/ directory importable
|
|
as top-level modules (``search``, ``fetch``, ``common``, ``cache``, ``_config``)
|
|
without requiring a package install.
|
|
"""
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
# Make scripts/ importable as top-level modules.
|
|
SCRIPTS_DIR = Path(__file__).resolve().parent.parent / "scripts"
|
|
if str(SCRIPTS_DIR) not in sys.path:
|
|
sys.path.insert(0, str(SCRIPTS_DIR))
|
|
|
|
import pytest
|
|
|
|
|
|
@pytest.fixture
|
|
def isolated_cache(monkeypatch, tmp_path):
|
|
"""Redirect the SQLite cache to a per-test temp directory.
|
|
|
|
``cache._cache_path()`` reads ``$SEARXNG_CACHE_DIR``; pointing it at a
|
|
fresh ``tmp_path`` keeps each test hermetic and prevents cross-test
|
|
contamination from leftover entries.
|
|
"""
|
|
monkeypatch.setenv("SEARXNG_CACHE_DIR", str(tmp_path))
|
|
return tmp_path
|