clipwright/tests/conftest.py
pedro-bento 91a5465f81
All checks were successful
CI / unit (push) Successful in 45s
CI / backend-e2e (push) Successful in 1m16s
CI / dashboard-e2e (push) Successful in 2m29s
chore: drop watermark feature, CLI, docs, design.md; consolidate requirements (#6)
- Remove the watermark feature end to end (watermarked.py, apply_watermark/
  mark_delivery/watermark_filter, WATERMARK env, assets/) and its tests; self-host
  delivery is now unconditionally clean.
- Delete the unused cli/ package and .github/workflows/publish-cli.yml.
- Delete docs/ (compliance) and design.md; drop the dangling references in the
  legal page and the design-token/ui comments.
- Consolidate requirements: requirements.txt (runtime) + requirements-test.txt
  (unit + E2E); remove requirements-e2e.txt and requirements-ml-e2e.txt and
  point both CI jobs at the single test file. Add libgl1 to the unit job
  (scenedetect -> opencv-python links libGL).

Verified in the CI container: unit 701 passed; API E2E 209; pipeline E2E 127;
Playwright 19 passed / 1 skipped.

Reviewed-on: #6
Co-authored-by: pedro-bento <mail@pbento.pt>
Co-committed-by: pedro-bento <mail@pbento.pt>
2026-10-05 11:11:37 +01:00

89 lines
2.5 KiB
Python

"""Shared pytest configuration.
The repo-root ``clipwright/`` package is made importable by
``[tool.pytest.ini_options] pythonpath = ["."]`` in the root ``pyproject.toml``,
so no manual ``sys.path`` manipulation is needed here.
The unit test environment deliberately omits the heavy ML stack
(torch/ultralytics/mediapipe/faster-whisper) so CI stays fast.
``clipwright.pipeline.main`` imports ``ultralytics`` and ``mediapipe`` at module
level, which made every test that does ``pytest.importorskip("...main")`` skip.
To keep that coverage without pulling gigabytes into CI, we install minimal
stand-ins *only when the real packages are absent* (the production image and a
developer machine with the real deps installed are unaffected).
"""
from __future__ import annotations
import sys
import types
from types import SimpleNamespace
class _FakeYOLO:
def __init__(self, *args, **kwargs):
self.args = args
def __call__(self, *args, **kwargs):
return []
def predict(self, *args, **kwargs):
return []
def track(self, *args, **kwargs):
return []
class _FakeDetection:
def __init__(self, *args, **kwargs):
pass
def process(self, *args, **kwargs):
return SimpleNamespace(detections=None)
def close(self):
pass
def _is_importable(name: str) -> bool:
try:
__import__(name)
return True
except Exception:
return False
def _install_heavy_stubs() -> None:
if not _is_importable("ultralytics"):
ultralytics = types.ModuleType("ultralytics")
ultralytics.YOLO = _FakeYOLO
sys.modules["ultralytics"] = ultralytics
if not _is_importable("mediapipe"):
mediapipe = types.ModuleType("mediapipe")
solutions = types.ModuleType("mediapipe.solutions")
def _solution(name: str) -> types.ModuleType:
mod = types.ModuleType(f"mediapipe.solutions.{name}")
mod.FaceDetection = _FakeDetection
mod.Detection = _FakeDetection
sys.modules[f"mediapipe.solutions.{name}"] = mod
return mod
for name in (
"face_detection",
"face_mesh",
"pose",
"hands",
"holistic",
"selfie_segmentation",
):
setattr(solutions, name, _solution(name))
mediapipe.solutions = solutions
sys.modules["mediapipe"] = mediapipe
sys.modules["mediapipe.solutions"] = solutions
_install_heavy_stubs()