|
4 | 4 | from __future__ import annotations |
5 | 5 |
|
6 | 6 | import asyncio |
| 7 | +import sys |
7 | 8 | from datetime import timedelta |
8 | 9 | from typing import TYPE_CHECKING |
9 | 10 |
|
10 | 11 | import pytest |
11 | 12 |
|
12 | 13 | from crawlee import Request, service_locator |
13 | 14 | from crawlee.configuration import Configuration |
14 | | -from crawlee.storage_clients import StorageClient |
| 15 | +from crawlee.storage_clients import MemoryStorageClient, StorageClient |
15 | 16 | from crawlee.storages import RequestQueue |
16 | 17 | from crawlee.storages._storage_instance_manager import StorageInstanceManager |
17 | 18 |
|
@@ -422,14 +423,20 @@ async def test_is_empty(rq: RequestQueue) -> None: |
422 | 423 | assert await rq.is_empty() is True |
423 | 424 |
|
424 | 425 |
|
| 426 | +# TODO: Remove this skip when #1498 is resolved. |
| 427 | +@pytest.mark.skipif(sys.platform != 'linux', reason='Flaky test on Windows, see #1498.') |
425 | 428 | @pytest.mark.parametrize( |
426 | 429 | ('wait_for_all'), |
427 | 430 | [ |
428 | 431 | pytest.param(True, id='wait for all'), |
429 | | - pytest.param(False, id='don`t wait for all'), |
| 432 | + pytest.param(False, id='do not wait for all'), |
430 | 433 | ], |
431 | 434 | ) |
432 | | -async def test_add_requests_wait_for_all(rq: RequestQueue, *, wait_for_all: bool) -> None: |
| 435 | +async def test_add_requests_wait_for_all( |
| 436 | + rq: RequestQueue, |
| 437 | + *, |
| 438 | + wait_for_all: bool, |
| 439 | +) -> None: |
433 | 440 | """Test adding requests with wait_for_all_requests_to_be_added option.""" |
434 | 441 | urls = [f'https://example.com/{i}' for i in range(15)] |
435 | 442 |
|
@@ -1034,7 +1041,7 @@ async def test_purge_on_start_enabled(storage_client: StorageClient) -> None: |
1034 | 1041 | """Test purge behavior when purge_on_start=True: named storages retain data, unnamed storages are purged.""" |
1035 | 1042 |
|
1036 | 1043 | # Skip this test for memory storage since it doesn't persist data between client instances. |
1037 | | - if storage_client.__class__.__name__ == 'MemoryStorageClient': |
| 1044 | + if isinstance(storage_client, MemoryStorageClient): |
1038 | 1045 | pytest.skip('Memory storage does not persist data between client instances.') |
1039 | 1046 |
|
1040 | 1047 | configuration = Configuration(purge_on_start=True) |
@@ -1160,7 +1167,7 @@ async def test_purge_on_start_disabled(storage_client: StorageClient) -> None: |
1160 | 1167 | """Test purge behavior when purge_on_start=False: all storages retain data regardless of type.""" |
1161 | 1168 |
|
1162 | 1169 | # Skip this test for memory storage since it doesn't persist data between client instances. |
1163 | | - if storage_client.__class__.__name__ == 'MemoryStorageClient': |
| 1170 | + if isinstance(storage_client, MemoryStorageClient): |
1164 | 1171 | pytest.skip('Memory storage does not persist data between client instances.') |
1165 | 1172 |
|
1166 | 1173 | configuration = Configuration(purge_on_start=False) |
|
0 commit comments