bot_host / tests /conftest.py
ItsBounvy's picture
deploy: english UI + admin creds + dataset wiring
76946d3 verified
Raw History Blame Contribute Delete
997 Bytes
"""Pytest bootstrap.
The package code uses flat imports (e.g. ``from config import PANEL_CONFIG``)
because on HuggingFace Spaces the ``hosting_panel/`` directory is uploaded
*flat* (no parent ``hosting_panel/`` folder on the Space). The tests,
written before that flat-upload convention, use package-style imports
(``from hosting_panel.auth import VAULT``).
To make both work locally, we prepend ``hosting_panel/`` to ``sys.path``
*before* any test module is collected. That way:
* ``from config import ...`` resolves to ``hosting_panel/config.py``.
* ``from hosting_panel.config import ...`` resolves to the package via
the same directory.
"""
from __future__ import annotations
import os
import sys
_HERE = os.path.dirname(__file__)
_PKG_DIR = os.path.dirname(_HERE) # .../hosting_panel/
# Prepend so flat imports win first; ``from hosting_panel.X`` still
# resolves via the same directory (Python falls back to scanning).
if _PKG_DIR not in sys.path:
sys.path.insert(0, _PKG_DIR)