Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion sentry_sdk/integrations/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ def patch_redis_client(cls, is_cluster):
This function can be used to instrument custom redis client classes or
subclasses.
"""

old_execute_command = cls.execute_command

def sentry_patched_execute_command(self, name, *args, **kwargs):
Expand Down
12 changes: 12 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from sentry_sdk.transport import Transport
from sentry_sdk.envelope import Envelope
from sentry_sdk.utils import capture_internal_exceptions
from sentry_sdk.integrations import _installed_integrations # noqa: F401

from tests import _warning_recorder, _warning_recorder_mgr

Expand Down Expand Up @@ -165,6 +166,17 @@ def inner(event):
return inner


@pytest.fixture
def reset_integrations():
"""
Use with caution, sometimes we really need to start
with a clean slate to ensure monkeypatching works well,
but this also means some other stuff will be monkeypatched twice.
"""
global _installed_integrations
_installed_integrations.clear()


@pytest.fixture
def sentry_init(monkeypatch_test_transport, request):
def inner(*a, **kw):
Expand Down
4 changes: 2 additions & 2 deletions tests/integrations/rediscluster/test_rediscluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
rediscluster_classes.append(rediscluster.StrictRedisCluster)


@pytest.fixture(scope="module", autouse=True)
def monkeypatch_rediscluster_classes():
@pytest.fixture(autouse=True)
def monkeypatch_rediscluster_classes(reset_integrations):

try:
pipeline_cls = rediscluster.ClusterPipeline
Expand Down
16 changes: 15 additions & 1 deletion tests/integrations/sanic/test_sanic.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
import sys

import random
import asyncio
from unittest.mock import Mock
Expand All @@ -18,6 +18,20 @@

@pytest.fixture
def app():
if SANIC_VERSION < (19,):
"""
Older Sanic versions 0.8 and 18 bind to the same fixed port which
creates problems when we run tests concurrently.
"""
old_test_client = Sanic.test_client.__get__

def new_test_client(self):
client = old_test_client(self, Sanic)
client.port += os.getpid() % 100
return client

Sanic.test_client = property(new_test_client)

if SANIC_VERSION >= (20, 12):
# Build (20.12.0) adds a feature where the instance is stored in an internal class
# registry for later retrieval, and so add register=False to disable that
Expand Down