Compare commits

...

2 Commits

Author SHA1 Message Date
CI Bot 96d4a42169 style: auto-format with black + isort + prettier [skip ci-format-check]
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 56s
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / PR Build Web Image (pull_request) Has been skipped
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 1m13s
AI Code Review / AI Code Review (pull_request) Failing after 1m13s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 1m13s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 1m27s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 1m50s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 1m52s
CI/CD Pipeline / Validate - Code Quality (pull_request) Successful in 2m57s
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Canary Release to Production (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
PR Automation / Auto Approve on CI Green (pull_request) Successful in 4m0s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 3m57s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 3m58s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 2m8s
CI/CD Pipeline / CI Gate (pull_request) Successful in 14s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 39s
ACR Cleanup / ACR Image Cleanup (pull_request_target) Successful in 8s
2026-08-15 09:52:19 +08:00
xiaoxia 71ca3a0d6e fix(test): add autouse fixture to reset worker_app.db module between tests
Add _reset_worker_app_db pytest fixture with autouse=True to prevent
mock pollution from leaking between tests. This fixes the flaky
test_batch_download_session_closed test that would fail when running
the full test suite due to worker_app.db being replaced with a
MagicMock from a previous test.
2026-08-15 09:52:19 +08:00
+15
View File
@@ -13,6 +13,21 @@ from unittest.mock import MagicMock, patch
import pytest
@pytest.fixture(autouse=True)
def _reset_worker_app_db():
"""Prevent mock pollution from leaking between tests."""
import importlib
import sys
# Save original module reference
original = sys.modules.get("worker_app.db")
yield
# Restore original module after each test
if original is not None:
sys.modules["worker_app.db"] = original
# ── Fake repository ─────────────────────────────────────────────────────────