Skip to content

Commit 59ffc0e

Browse files
authored
chore: skip problematic and flaky tests (#1497)
1 parent af237da commit 59ffc0e

File tree

5 files changed

+25
-9
lines changed

5 files changed

+25
-9
lines changed

tests/unit/_utils/test_sitemap.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import base64
22
import gzip
3+
import sys
34
from datetime import datetime
45

6+
import pytest
57
from yarl import URL
68

79
from crawlee._utils.sitemap import Sitemap, SitemapUrl, parse_sitemap
@@ -93,6 +95,8 @@ async def test_gzipped_sitemap(server_url: URL, http_client: HttpClient) -> None
9395
assert set(sitemap.urls) == BASIC_RESULTS
9496

9597

98+
# TODO: Remove this skip when #1460 is resolved.
99+
@pytest.mark.skipif(sys.platform != 'linux', reason='Flaky with Curl on Windows, see #1460.')
96100
async def test_gzipped_sitemap_with_invalid_data(server_url: URL, http_client: HttpClient) -> None:
97101
"""Test loading a invalid gzipped sitemap with correct type and .xml.gz url."""
98102
compress_data = compress_gzip(BASIC_SITEMAP)

tests/unit/http_clients/test_http_clients.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
import os
4+
import sys
45
from typing import TYPE_CHECKING
56

67
import pytest
@@ -163,6 +164,10 @@ async def test_send_request_allow_redirects_false(custom_http_client: HttpClient
163164

164165

165166
async def test_stream(http_client: HttpClient, server_url: URL) -> None:
167+
# TODO: Remove this skip when #1494 is resolved.
168+
if isinstance(http_client, CurlImpersonateHttpClient) and sys.platform != 'linux':
169+
pytest.skip('Flaky with Curl on Windows, see #1494.')
170+
166171
content_body: bytes = b''
167172

168173
async with http_client.stream(str(server_url)) as response:

tests/unit/storages/test_dataset.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,7 @@ async def test_purge_on_start_enabled(storage_client: StorageClient) -> None:
875875
"""Test purge behavior when purge_on_start=True: named storages retain data, unnamed storages are purged."""
876876

877877
# Skip this test for memory storage since it doesn't persist data between client instances.
878-
if storage_client.__class__ == MemoryStorageClient:
878+
if isinstance(storage_client, MemoryStorageClient):
879879
pytest.skip('Memory storage does not persist data between client instances.')
880880

881881
configuration = Configuration(purge_on_start=True)
@@ -961,7 +961,7 @@ async def test_purge_on_start_disabled(storage_client: StorageClient) -> None:
961961
"""Test purge behavior when purge_on_start=False: all storages retain data regardless of type."""
962962

963963
# Skip this test for memory storage since it doesn't persist data between client instances.
964-
if storage_client.__class__ == MemoryStorageClient:
964+
if isinstance(storage_client, MemoryStorageClient):
965965
pytest.skip('Memory storage does not persist data between client instances.')
966966

967967
configuration = Configuration(purge_on_start=False)

tests/unit/storages/test_key_value_store.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,7 @@ async def test_purge_on_start_enabled(storage_client: StorageClient) -> None:
898898
"""Test purge behavior when purge_on_start=True: named storages retain data, unnamed storages are purged."""
899899

900900
# Skip this test for memory storage since it doesn't persist data between client instances.
901-
if storage_client.__class__.__name__ == 'MemoryStorageClient':
901+
if isinstance(storage_client, MemoryStorageClient):
902902
pytest.skip('Memory storage does not persist data between client instances.')
903903

904904
configuration = Configuration(purge_on_start=True)
@@ -984,7 +984,7 @@ async def test_purge_on_start_disabled(storage_client: StorageClient) -> None:
984984
"""Test purge behavior when purge_on_start=False: all storages retain data regardless of type."""
985985

986986
# Skip this test for memory storage since it doesn't persist data between client instances.
987-
if storage_client.__class__.__name__ == 'MemoryStorageClient':
987+
if isinstance(storage_client, MemoryStorageClient):
988988
pytest.skip('Memory storage does not persist data between client instances.')
989989

990990
configuration = Configuration(purge_on_start=False)

tests/unit/storages/test_request_queue.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
from __future__ import annotations
55

66
import asyncio
7+
import sys
78
from datetime import timedelta
89
from typing import TYPE_CHECKING
910

1011
import pytest
1112

1213
from crawlee import Request, service_locator
1314
from crawlee.configuration import Configuration
14-
from crawlee.storage_clients import StorageClient
15+
from crawlee.storage_clients import MemoryStorageClient, StorageClient
1516
from crawlee.storages import RequestQueue
1617
from crawlee.storages._storage_instance_manager import StorageInstanceManager
1718

@@ -422,14 +423,20 @@ async def test_is_empty(rq: RequestQueue) -> None:
422423
assert await rq.is_empty() is True
423424

424425

426+
# TODO: Remove this skip when #1498 is resolved.
427+
@pytest.mark.skipif(sys.platform != 'linux', reason='Flaky test on Windows, see #1498.')
425428
@pytest.mark.parametrize(
426429
('wait_for_all'),
427430
[
428431
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'),
430433
],
431434
)
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:
433440
"""Test adding requests with wait_for_all_requests_to_be_added option."""
434441
urls = [f'https://example.com/{i}' for i in range(15)]
435442

@@ -1034,7 +1041,7 @@ async def test_purge_on_start_enabled(storage_client: StorageClient) -> None:
10341041
"""Test purge behavior when purge_on_start=True: named storages retain data, unnamed storages are purged."""
10351042

10361043
# 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):
10381045
pytest.skip('Memory storage does not persist data between client instances.')
10391046

10401047
configuration = Configuration(purge_on_start=True)
@@ -1160,7 +1167,7 @@ async def test_purge_on_start_disabled(storage_client: StorageClient) -> None:
11601167
"""Test purge behavior when purge_on_start=False: all storages retain data regardless of type."""
11611168

11621169
# 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):
11641171
pytest.skip('Memory storage does not persist data between client instances.')
11651172

11661173
configuration = Configuration(purge_on_start=False)

0 commit comments

Comments
 (0)