diff --git a/tests/test_squeues_request.py b/tests/test_squeues_request.py index b26299663..3765a6488 100644 --- a/tests/test_squeues_request.py +++ b/tests/test_squeues_request.py @@ -4,6 +4,7 @@ Queues that handle requests from __future__ import annotations +import gc from abc import ABC, abstractmethod from typing import TYPE_CHECKING, Any @@ -242,8 +243,11 @@ def test_sqlite_queue_survives_unclean_shutdown( key = str(tmp_path / "queue") queue = queue_cls.from_crawler(crawler=crawler, key=key) queue.push(Request("https://toscrape.com")) - # No close(), as if the process had been killed. + # No close(), as if the process had been killed. The SQLite connection is + # part of a reference cycle, so a garbage collection is needed to release + # the underlying file, which on Windows cannot be removed while open. del queue + gc.collect() queue = queue_cls.from_crawler(crawler=crawler, key=key) try: