File tree Expand file tree Collapse file tree
tests/external_storage_redis Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44
55import math
66from datetime import timedelta
7-
8- from redis .asyncio .client import Redis
7+ from typing import TYPE_CHECKING
98
109from external_storage_redis ._client import RedisStorageDriverClient
1110
11+ if TYPE_CHECKING :
12+ from redis .asyncio .client import Redis
13+
1214
1315class _RedisAsyncioStorageDriverClient (RedisStorageDriverClient ):
1416 """Adapter that wraps a ``redis.asyncio.Redis`` client.
Original file line number Diff line number Diff line change 33from __future__ import annotations
44
55from collections .abc import AsyncIterator
6+ from typing import TYPE_CHECKING
67
78import fakeredis .aioredis
89import pytest
910import pytest_asyncio
10- from redis .asyncio .client import Redis
1111
1212from external_storage_redis import RedisStorageDriverClient
1313from external_storage_redis .redis_asyncio import new_redis_asyncio_client
1414
15+ if TYPE_CHECKING :
16+ from redis .asyncio .client import Redis
17+
1518KEY_PREFIX = "test:payloads"
1619
1720
Original file line number Diff line number Diff line change 44
55import asyncio
66import hashlib
7+ import subprocess
8+ import sys
79from collections .abc import Callable , Coroutine
810from datetime import timedelta
911from functools import wraps
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+
3353def make_payload (value : str = "hello" ) -> Payload :
3454 payload = _CONVERTER .to_payload (value )
3555 assert payload is not None
You can’t perform that action at this time.
0 commit comments