Skip to content

Commit 52a7c26

Browse files
authored
test: Mock attributes in redis cluster tests (#7022)
### Description Redis started accessing an internal attribute on the Pipeline class, which threw an `AttributeError` in our tests since we were not mocking the class fully. Also, set up `pytest-asyncio` in Python 3.14 so that we can run async tests. #### Issues Closes #6974 #### Reminders - Please add tests to validate your changes, and lint your code using `uv run ruff`. - Add GH Issue ID _&_ Linear ID (if applicable) - PR title should use [conventional commit](https://develop.sentry.dev/engineering-practices/commit-messages/#type) style (`feat:`, `fix:`, `ref:`, `meta:`) - For external contributors: [CONTRIBUTING.md](https://github.com/getsentry/sentry-python/blob/master/CONTRIBUTING.md), [Sentry SDK development docs](https://develop.sentry.dev/sdk/), [Discord community](https://discord.gg/Ww9hbqr)
1 parent 5c8d0f2 commit 52a7c26

5 files changed

Lines changed: 80 additions & 57 deletions

File tree

scripts/populate_tox/config.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,9 @@
425425
"*": ["fakeredis!=1.7.4", "pytest<8.0.0"],
426426
">=4.0,<5.0": ["fakeredis<2.31.0"],
427427
"py3.6,py3.7,py3.8": ["fakeredis<2.26.0"],
428-
"py3.7,py3.8,py3.9,py3.10,py3.11,py3.12,py3.13": ["pytest-asyncio"],
428+
"py3.7,py3.8,py3.9,py3.10,py3.11,py3.12,py3.13,py3.14,py3.14t": [
429+
"pytest-asyncio"
430+
],
429431
},
430432
},
431433
"redis_py_cluster_legacy": {

scripts/populate_tox/package_dependencies.jsonl

Lines changed: 8 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/populate_tox/releases.jsonl

Lines changed: 12 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/integrations/redis/cluster/test_redis_cluster.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from unittest.mock import MagicMock
2+
13
import pytest
24
import redis
35

@@ -14,7 +16,9 @@ def monkeypatch_rediscluster_class(reset_integrations):
1416
pipeline_cls = redis.cluster.ClusterPipeline
1517
redis.cluster.NodesManager.initialize = lambda *_, **__: None
1618
redis.RedisCluster.command = lambda *_: []
17-
redis.RedisCluster.pipeline = lambda *_, **__: pipeline_cls(None, None)
19+
redis.RedisCluster.pipeline = lambda *_, **__: pipeline_cls(
20+
MagicMock(), MagicMock()
21+
)
1822
redis.RedisCluster.get_default_node = lambda *_, **__: redis.cluster.ClusterNode(
1923
"localhost", 6379
2024
)

tox.ini

Lines changed: 52 additions & 46 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)