From 992e0c8d229e79167206882c854f98f8a38cfbba Mon Sep 17 00:00:00 2001 From: jxxghp Date: Fri, 16 Oct 2026 23:18:09 +0800 Subject: [PATCH] test: isolate transactional download history rows --- tests/test_transactional_download_history.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/test_transactional_download_history.py b/tests/test_transactional_download_history.py index 2af55b8ed..e9c1a7e5f 100644 --- a/tests/test_transactional_download_history.py +++ b/tests/test_transactional_download_history.py @@ -14,12 +14,18 @@ from app.db.adapters.history.download import ( SessionDownloadHistoryRepository, TransactionalDownloadHistoryRepository, ) -from app.db.models.downloadhistory import DownloadHistory +from app.db.models.downloadhistory import DownloadFiles, DownloadHistory from app.db.session import SessionFactory, async_session_scope from app.db.uow import SqlAlchemyUnitOfWork from app.schemas.types import MediaSource, MediaType +@pytest.fixture(autouse=True) +def _track(db) -> None: + """回收仓储通过独立事务写入的历史与文件,避免污染后续用例。""" + db.watermark(DownloadHistory, DownloadFiles) + + def _repository() -> TransactionalDownloadHistoryRepository: """构造绑定测试数据库短 Session 的下载历史仓储。""" return TransactionalDownloadHistoryRepository(