Skip to content

Commit 999e231

Browse files
committed
Fix CI tests
1 parent f0b5830 commit 999e231

3 files changed

Lines changed: 28 additions & 3 deletions

File tree

external_storage_redis/redis_asyncio.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44

55
import math
66
from datetime import timedelta
7-
8-
from redis.asyncio.client import Redis
7+
from typing import TYPE_CHECKING
98

109
from external_storage_redis._client import RedisStorageDriverClient
1110

11+
if TYPE_CHECKING:
12+
from redis.asyncio.client import Redis
13+
1214

1315
class _RedisAsyncioStorageDriverClient(RedisStorageDriverClient):
1416
"""Adapter that wraps a ``redis.asyncio.Redis`` client.

tests/external_storage_redis/conftest.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,18 @@
33
from __future__ import annotations
44

55
from collections.abc import AsyncIterator
6+
from typing import TYPE_CHECKING
67

78
import fakeredis.aioredis
89
import pytest
910
import pytest_asyncio
10-
from redis.asyncio.client import Redis
1111

1212
from external_storage_redis import RedisStorageDriverClient
1313
from external_storage_redis.redis_asyncio import new_redis_asyncio_client
1414

15+
if TYPE_CHECKING:
16+
from redis.asyncio.client import Redis
17+
1518
KEY_PREFIX = "test:payloads"
1619

1720

tests/external_storage_redis/test_redis.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
import asyncio
66
import hashlib
7+
import subprocess
8+
import sys
79
from collections.abc import Callable, Coroutine
810
from datetime import timedelta
911
from functools import wraps
@@ -30,6 +32,24 @@
3032
_CONVERTER = JSONPlainPayloadConverter()
3133

3234

35+
def test_redis_asyncio_adapter_import_is_workflow_safe() -> None:
36+
completed = subprocess.run(
37+
[
38+
sys.executable,
39+
"-c",
40+
(
41+
"import sys; "
42+
"import external_storage_redis.redis_asyncio; "
43+
"print(any(name.startswith('redis.asyncio') for name in sys.modules))"
44+
),
45+
],
46+
check=True,
47+
capture_output=True,
48+
text=True,
49+
)
50+
assert completed.stdout.strip() == "False"
51+
52+
3353
def make_payload(value: str = "hello") -> Payload:
3454
payload = _CONVERTER.to_payload(value)
3555
assert payload is not None

0 commit comments

Comments
 (0)