From 6ec17f1e8a95299b8e5fe84e02fbf80353270e2d Mon Sep 17 00:00:00 2001 From: Ivana Kellyerova Date: Tue, 16 Jan 2024 17:29:08 +0100 Subject: [PATCH 1/5] Remove Python <= 3.5 compatibity code in tests --- tests/conftest.py | 18 ++-------- tests/integrations/aiohttp/test_aiohttp.py | 6 +--- tests/integrations/asgi/test_asgi.py | 24 -------------- .../integrations/asyncio/test_asyncio_py3.py | 6 +--- tests/integrations/aws_lambda/test_aws.py | 5 +-- tests/integrations/boto3/test_s3.py | 10 ++---- tests/integrations/celery/test_celery.py | 11 ++----- .../celery/test_celery_beat_crons.py | 18 +++------- .../test_cloud_resource_context.py | 9 ++--- tests/integrations/django/asgi/test_asgi.py | 5 +-- .../integrations/django/test_transactions.py | 6 +--- tests/integrations/fastapi/test_fastapi.py | 12 +++---- tests/integrations/gcp/test_gcp.py | 4 --- tests/integrations/httpx/test_httpx.py | 8 ++--- .../opentelemetry/test_experimental.py | 7 +--- .../opentelemetry/test_propagator.py | 9 ++--- .../opentelemetry/test_span_processor.py | 15 +++------ tests/integrations/redis/test_redis.py | 10 ++---- tests/integrations/requests/test_requests.py | 10 ++---- tests/integrations/rq/test_rq.py | 11 +++---- .../sqlalchemy/test_sqlalchemy.py | 4 --- .../integrations/starlette/test_starlette.py | 12 ++----- tests/integrations/stdlib/test_httplib.py | 23 ++----------- .../integrations/threading/test_threading.py | 33 +------------------ tests/integrations/wsgi/test_wsgi.py | 11 ++----- tests/test_api.py | 7 ++-- tests/test_client.py | 13 +++----- tests/test_crons.py | 9 ++--- tests/test_metrics.py | 6 +--- tests/test_monitor.py | 6 +--- tests/test_profiler.py | 33 ++----------------- tests/test_scope.py | 7 ++-- tests/test_serializer.py | 4 +-- tests/test_sessions.py | 8 ++--- tests/test_transport.py | 11 ++----- tests/test_utils.py | 16 ++------- tests/tracing/test_decorator_sync.py | 7 ++-- tests/tracing/test_http_headers.py | 8 ++--- tests/tracing/test_misc.py | 9 ++--- tests/tracing/test_sampling.py | 6 +--- tests/utils/test_transaction.py | 11 +------ 41 files changed, 83 insertions(+), 365 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 85c65462cb..3f556155f0 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -3,6 +3,8 @@ import socket from threading import Thread from contextlib import contextmanager +from http.server import BaseHTTPRequestHandler, HTTPServer +from unittest import mock import pytest import jsonschema @@ -17,22 +19,6 @@ except ImportError: eventlet = None -try: - # Python 2 - import BaseHTTPServer - - HTTPServer = BaseHTTPServer.HTTPServer - BaseHTTPRequestHandler = BaseHTTPServer.BaseHTTPRequestHandler -except Exception: - # Python 3 - from http.server import BaseHTTPRequestHandler, HTTPServer - - -try: - from unittest import mock -except ImportError: - import mock - import sentry_sdk from sentry_sdk._compat import iteritems, reraise, string_types, PY2 from sentry_sdk.envelope import Envelope diff --git a/tests/integrations/aiohttp/test_aiohttp.py b/tests/integrations/aiohttp/test_aiohttp.py index 8068365334..47dd03cdbc 100644 --- a/tests/integrations/aiohttp/test_aiohttp.py +++ b/tests/integrations/aiohttp/test_aiohttp.py @@ -1,6 +1,7 @@ import asyncio import json from contextlib import suppress +from unittest import mock import pytest from aiohttp import web @@ -10,11 +11,6 @@ from sentry_sdk import capture_message, start_transaction from sentry_sdk.integrations.aiohttp import AioHttpIntegration -try: - from unittest import mock # python 3.3 and above -except ImportError: - import mock # python < 3.3 - @pytest.mark.asyncio async def test_basic(sentry_init, aiohttp_client, capture_events): diff --git a/tests/integrations/asgi/test_asgi.py b/tests/integrations/asgi/test_asgi.py index d60991e99e..f4b5404047 100644 --- a/tests/integrations/asgi/test_asgi.py +++ b/tests/integrations/asgi/test_asgi.py @@ -1,5 +1,3 @@ -import sys - from collections import Counter import pytest @@ -11,11 +9,6 @@ from async_asgi_testclient import TestClient -minimum_python_36 = pytest.mark.skipif( - sys.version_info < (3, 6), reason="ASGI is only supported in Python >= 3.6" -) - - @pytest.fixture def asgi3_app(): async def app(scope, receive, send): @@ -133,7 +126,6 @@ async def app(scope, receive, send): return app -@minimum_python_36 def test_invalid_transaction_style(asgi3_app): with pytest.raises(ValueError) as exp: SentryAsgiMiddleware(asgi3_app, transaction_style="URL") @@ -144,7 +136,6 @@ def test_invalid_transaction_style(asgi3_app): ) -@minimum_python_36 @pytest.mark.asyncio async def test_capture_transaction( sentry_init, @@ -176,7 +167,6 @@ async def test_capture_transaction( } -@minimum_python_36 @pytest.mark.asyncio async def test_capture_transaction_with_error( sentry_init, @@ -214,7 +204,6 @@ async def test_capture_transaction_with_error( assert transaction_event["request"] == error_event["request"] -@minimum_python_36 @pytest.mark.asyncio async def test_has_trace_if_performance_enabled( sentry_init, @@ -247,7 +236,6 @@ async def test_has_trace_if_performance_enabled( ) -@minimum_python_36 @pytest.mark.asyncio async def test_has_trace_if_performance_disabled( sentry_init, @@ -271,7 +259,6 @@ async def test_has_trace_if_performance_disabled( assert "trace_id" in error_event["contexts"]["trace"] -@minimum_python_36 @pytest.mark.asyncio async def test_trace_from_headers_if_performance_enabled( sentry_init, @@ -305,7 +292,6 @@ async def test_trace_from_headers_if_performance_enabled( assert transaction_event["contexts"]["trace"]["trace_id"] == trace_id -@minimum_python_36 @pytest.mark.asyncio async def test_trace_from_headers_if_performance_disabled( sentry_init, @@ -334,7 +320,6 @@ async def test_trace_from_headers_if_performance_disabled( assert error_event["contexts"]["trace"]["trace_id"] == trace_id -@minimum_python_36 @pytest.mark.asyncio async def test_websocket(sentry_init, asgi3_ws_app, capture_events, request): sentry_init(debug=True, send_default_pii=True) @@ -367,7 +352,6 @@ async def test_websocket(sentry_init, asgi3_ws_app, capture_events, request): assert exc["value"] == "Oh no" -@minimum_python_36 @pytest.mark.asyncio async def test_auto_session_tracking_with_aggregates( sentry_init, asgi3_app, capture_envelopes @@ -406,7 +390,6 @@ async def test_auto_session_tracking_with_aggregates( assert len(session_aggregates) == 1 -@minimum_python_36 @pytest.mark.parametrize( "url,transaction_style,expected_transaction,expected_source", [ @@ -470,7 +453,6 @@ async def __call__(): pass -@minimum_python_36 def test_looks_like_asgi3(asgi3_app): # branch: inspect.isclass(app) assert _looks_like_asgi3(MockAsgi3App) @@ -487,7 +469,6 @@ def test_looks_like_asgi3(asgi3_app): assert not _looks_like_asgi3(asgi2) -@minimum_python_36 def test_get_ip_x_forwarded_for(): headers = [ (b"x-forwarded-for", b"8.8.8.8"), @@ -525,7 +506,6 @@ def test_get_ip_x_forwarded_for(): assert ip == "5.5.5.5" -@minimum_python_36 def test_get_ip_x_real_ip(): headers = [ (b"x-real-ip", b"10.10.10.10"), @@ -550,7 +530,6 @@ def test_get_ip_x_real_ip(): assert ip == "8.8.8.8" -@minimum_python_36 def test_get_ip(): # if now headers are provided the ip is taken from the client. headers = [] @@ -584,7 +563,6 @@ def test_get_ip(): assert ip == "10.10.10.10" -@minimum_python_36 def test_get_headers(): headers = [ (b"x-real-ip", b"10.10.10.10"), @@ -602,7 +580,6 @@ def test_get_headers(): } -@minimum_python_36 @pytest.mark.asyncio @pytest.mark.parametrize( "request_url,transaction_style,expected_transaction_name,expected_transaction_source", @@ -654,7 +631,6 @@ async def test_transaction_name( ) -@minimum_python_36 @pytest.mark.asyncio @pytest.mark.parametrize( "request_url, transaction_style,expected_transaction_name,expected_transaction_source", diff --git a/tests/integrations/asyncio/test_asyncio_py3.py b/tests/integrations/asyncio/test_asyncio_py3.py index c563f37b7d..681c076624 100644 --- a/tests/integrations/asyncio/test_asyncio_py3.py +++ b/tests/integrations/asyncio/test_asyncio_py3.py @@ -1,6 +1,7 @@ import asyncio import inspect import sys +from unittest.mock import MagicMock, patch import pytest @@ -8,11 +9,6 @@ from sentry_sdk.consts import OP from sentry_sdk.integrations.asyncio import AsyncioIntegration, patch_asyncio -try: - from unittest.mock import MagicMock, patch -except ImportError: - from mock import MagicMock, patch - try: from contextvars import Context, ContextVar except ImportError: diff --git a/tests/integrations/aws_lambda/test_aws.py b/tests/integrations/aws_lambda/test_aws.py index 7141e2a7cb..29d2d384d6 100644 --- a/tests/integrations/aws_lambda/test_aws.py +++ b/tests/integrations/aws_lambda/test_aws.py @@ -600,10 +600,7 @@ def test_traces_sampler_gets_correct_values_in_sampling_context( + dedent(inspect.getsource(ObjectDescribedBy)) + dedent( """ - try: - from unittest import mock # python 3.3 and above - except ImportError: - import mock # python < 3.3 + from unittest import mock def _safe_is_equal(x, y): # copied from conftest.py - see docstring and comments there diff --git a/tests/integrations/boto3/test_s3.py b/tests/integrations/boto3/test_s3.py index 5812c2c1bb..b2d09bc5a3 100644 --- a/tests/integrations/boto3/test_s3.py +++ b/tests/integrations/boto3/test_s3.py @@ -1,16 +1,12 @@ -import pytest +from unittest import mock import boto3 +import pytest from sentry_sdk import Hub from sentry_sdk.integrations.boto3 import Boto3Integration -from tests.integrations.boto3.aws_mock import MockResponse from tests.integrations.boto3 import read_fixture - -try: - from unittest import mock # python 3.3 and above -except ImportError: - import mock # python < 3.3 +from tests.integrations.boto3.aws_mock import MockResponse session = boto3.Session( diff --git a/tests/integrations/celery/test_celery.py b/tests/integrations/celery/test_celery.py index 0d44ee992e..5d007d4a4a 100644 --- a/tests/integrations/celery/test_celery.py +++ b/tests/integrations/celery/test_celery.py @@ -1,6 +1,9 @@ import threading +from unittest import mock import pytest +from celery import Celery, VERSION +from celery.bin import worker from sentry_sdk import Hub, configure_scope, start_transaction, get_current_span from sentry_sdk.integrations.celery import ( @@ -11,14 +14,6 @@ from sentry_sdk._compat import text_type -from celery import Celery, VERSION -from celery.bin import worker - -try: - from unittest import mock # python 3.3 and above -except ImportError: - import mock # python < 3.3 - @pytest.fixture def connect_signal(request): diff --git a/tests/integrations/celery/test_celery_beat_crons.py b/tests/integrations/celery/test_celery_beat_crons.py index 9343b3c926..d5ef3a1a22 100644 --- a/tests/integrations/celery/test_celery_beat_crons.py +++ b/tests/integrations/celery/test_celery_beat_crons.py @@ -1,8 +1,11 @@ import datetime -import sys +from unittest import mock +from unittest.mock import MagicMock import pytest +from celery.schedules import crontab, schedule +from sentry_sdk.crons import MonitorStatus from sentry_sdk.integrations.celery import ( _get_headers, _get_humanized_interval, @@ -12,15 +15,6 @@ crons_task_failure, crons_task_retry, ) -from sentry_sdk.crons import MonitorStatus -from celery.schedules import crontab, schedule - -try: - from unittest import mock # python 3.3 and above - from unittest.mock import MagicMock -except ImportError: - import mock # python < 3.3 - from mock import MagicMock def test_get_headers(): @@ -378,10 +372,6 @@ def test_get_monitor_config_timezone_in_app_conf(): assert monitor_config["timezone"] == "Asia/Karachi" -@pytest.mark.skipif( - sys.version_info < (3, 0), - reason="no datetime.timezone for Python 2, so skipping this test.", -) def test_get_monitor_config_timezone_in_celery_schedule(): app = MagicMock() app.timezone = "Asia/Karachi" diff --git a/tests/integrations/cloud_resource_context/test_cloud_resource_context.py b/tests/integrations/cloud_resource_context/test_cloud_resource_context.py index b36f795a2b..065db0d09e 100644 --- a/tests/integrations/cloud_resource_context/test_cloud_resource_context.py +++ b/tests/integrations/cloud_resource_context/test_cloud_resource_context.py @@ -1,14 +1,9 @@ import json +from unittest import mock # python 3.3 and above +from unittest.mock import MagicMock import pytest -try: - from unittest import mock # python 3.3 and above - from unittest.mock import MagicMock -except ImportError: - import mock # python < 3.3 - from mock import MagicMock - from sentry_sdk.integrations.cloud_resource_context import ( CLOUD_PLATFORM, CLOUD_PROVIDER, diff --git a/tests/integrations/django/asgi/test_asgi.py b/tests/integrations/django/asgi/test_asgi.py index 21a72e4a32..aff8c54ded 100644 --- a/tests/integrations/django/asgi/test_asgi.py +++ b/tests/integrations/django/asgi/test_asgi.py @@ -1,6 +1,7 @@ import base64 import json import os +from unittest import mock import django import pytest @@ -14,10 +15,6 @@ except ImportError: from django.core.urlresolvers import reverse -try: - from unittest import mock # python 3.3 and above -except ImportError: - import mock # python < 3.3 APPS = [channels_application] if django.VERSION >= (3, 0): diff --git a/tests/integrations/django/test_transactions.py b/tests/integrations/django/test_transactions.py index c9914c8ec5..d3094a064d 100644 --- a/tests/integrations/django/test_transactions.py +++ b/tests/integrations/django/test_transactions.py @@ -1,13 +1,9 @@ from __future__ import absolute_import +from unittest import mock import pytest import django -try: - from unittest import mock # python 3.3 and above -except ImportError: - import mock # python < 3.3 - # django<2.0 has only `url` with regex based patterns. # django>=2.0 renames `url` to `re_path`, and additionally introduces `path` diff --git a/tests/integrations/fastapi/test_fastapi.py b/tests/integrations/fastapi/test_fastapi.py index 56d52be474..b5d71b4532 100644 --- a/tests/integrations/fastapi/test_fastapi.py +++ b/tests/integrations/fastapi/test_fastapi.py @@ -1,21 +1,17 @@ import json import logging import threading +from unittest import mock import pytest -from sentry_sdk.integrations.fastapi import FastApiIntegration - from fastapi import FastAPI, Request from fastapi.testclient import TestClient from fastapi.middleware.trustedhost import TrustedHostMiddleware + from sentry_sdk import capture_message -from sentry_sdk.integrations.starlette import StarletteIntegration from sentry_sdk.integrations.asgi import SentryAsgiMiddleware - -try: - from unittest import mock # python 3.3 and above -except ImportError: - import mock # python < 3.3 +from sentry_sdk.integrations.fastapi import FastApiIntegration +from sentry_sdk.integrations.starlette import StarletteIntegration def fastapi_app_factory(): diff --git a/tests/integrations/gcp/test_gcp.py b/tests/integrations/gcp/test_gcp.py index 678219dc8b..2aebdf763e 100644 --- a/tests/integrations/gcp/test_gcp.py +++ b/tests/integrations/gcp/test_gcp.py @@ -12,10 +12,6 @@ import os.path import os -pytestmark = pytest.mark.skipif( - not hasattr(tempfile, "TemporaryDirectory"), reason="need Python 3.2+" -) - FUNCTIONS_PRELUDE = """ from unittest.mock import Mock diff --git a/tests/integrations/httpx/test_httpx.py b/tests/integrations/httpx/test_httpx.py index e141faa282..74a7566e3e 100644 --- a/tests/integrations/httpx/test_httpx.py +++ b/tests/integrations/httpx/test_httpx.py @@ -1,18 +1,14 @@ import asyncio +from unittest import mock -import pytest import httpx +import pytest import responses from sentry_sdk import capture_message, start_transaction from sentry_sdk.consts import MATCH_ALL, SPANDATA from sentry_sdk.integrations.httpx import HttpxIntegration -try: - from unittest import mock # python 3.3 and above -except ImportError: - import mock # python < 3.3 - @pytest.mark.parametrize( "httpx_client", diff --git a/tests/integrations/opentelemetry/test_experimental.py b/tests/integrations/opentelemetry/test_experimental.py index 77286330a5..e71341a7d4 100644 --- a/tests/integrations/opentelemetry/test_experimental.py +++ b/tests/integrations/opentelemetry/test_experimental.py @@ -1,9 +1,4 @@ -try: - # python 3.3 and above - from unittest.mock import MagicMock -except ImportError: - # python < 3.3 - from mock import MagicMock +from unittest.mock import MagicMock from sentry_sdk.integrations.opentelemetry.integration import OpenTelemetryIntegration diff --git a/tests/integrations/opentelemetry/test_propagator.py b/tests/integrations/opentelemetry/test_propagator.py index 510118f67f..1283dc0525 100644 --- a/tests/integrations/opentelemetry/test_propagator.py +++ b/tests/integrations/opentelemetry/test_propagator.py @@ -1,9 +1,5 @@ -try: - from unittest import mock # python 3.3 and above - from unittest.mock import MagicMock -except ImportError: - import mock # python < 3.3 - from mock import MagicMock +from unittest import mock +from unittest.mock import MagicMock from opentelemetry.context import get_current from opentelemetry.trace.propagation import get_current_span @@ -16,7 +12,6 @@ SENTRY_BAGGAGE_KEY, SENTRY_TRACE_KEY, ) - from sentry_sdk.integrations.opentelemetry.propagator import SentryPropagator from sentry_sdk.integrations.opentelemetry.span_processor import SentrySpanProcessor from sentry_sdk.tracing_utils import Baggage diff --git a/tests/integrations/opentelemetry/test_span_processor.py b/tests/integrations/opentelemetry/test_span_processor.py index 679e51e808..e799c21f96 100644 --- a/tests/integrations/opentelemetry/test_span_processor.py +++ b/tests/integrations/opentelemetry/test_span_processor.py @@ -1,21 +1,16 @@ -from datetime import datetime import time -import pytest +from datetime import datetime +from unittest import mock +from unittest.mock import MagicMock -try: - from unittest import mock # python 3.3 and above - from unittest.mock import MagicMock -except ImportError: - import mock - from mock import MagicMock # python < 3.3 +import pytest +from opentelemetry.trace import SpanKind, SpanContext, Status, StatusCode from sentry_sdk.integrations.opentelemetry.span_processor import ( SentrySpanProcessor, link_trace_context_to_error_event, ) from sentry_sdk.tracing import Span, Transaction - -from opentelemetry.trace import SpanKind, SpanContext, Status, StatusCode from sentry_sdk.tracing_utils import extract_sentrytrace_data diff --git a/tests/integrations/redis/test_redis.py b/tests/integrations/redis/test_redis.py index d25e630f6a..57ac1c9ab1 100644 --- a/tests/integrations/redis/test_redis.py +++ b/tests/integrations/redis/test_redis.py @@ -1,16 +1,12 @@ +from unittest import mock + import pytest +from fakeredis import FakeStrictRedis from sentry_sdk import capture_message, start_transaction from sentry_sdk.consts import SPANDATA from sentry_sdk.integrations.redis import RedisIntegration -from fakeredis import FakeStrictRedis - -try: - from unittest import mock # python 3.3 and above -except ImportError: - import mock # python < 3.3 - MOCK_CONNECTION_POOL = mock.MagicMock() MOCK_CONNECTION_POOL.connection_kwargs = { diff --git a/tests/integrations/requests/test_requests.py b/tests/integrations/requests/test_requests.py index ed5b273712..04e89915d9 100644 --- a/tests/integrations/requests/test_requests.py +++ b/tests/integrations/requests/test_requests.py @@ -1,17 +1,13 @@ -import requests -import responses +from unittest import mock import pytest +import requests +import responses from sentry_sdk import capture_message from sentry_sdk.consts import SPANDATA from sentry_sdk.integrations.stdlib import StdlibIntegration -try: - from unittest import mock # python 3.3 and above -except ImportError: - import mock # python < 3.3 - def test_crumb_capture(sentry_init, capture_events): sentry_init(integrations=[StdlibIntegration()]) diff --git a/tests/integrations/rq/test_rq.py b/tests/integrations/rq/test_rq.py index b0d71e8f7d..3f2218c945 100644 --- a/tests/integrations/rq/test_rq.py +++ b/tests/integrations/rq/test_rq.py @@ -1,16 +1,13 @@ +from unittest import mock + import pytest +import rq from fakeredis import FakeStrictRedis + from sentry_sdk import configure_scope, start_transaction from sentry_sdk.integrations.rq import RqIntegration from sentry_sdk.utils import parse_version -import rq - -try: - from unittest import mock # python 3.3 and above -except ImportError: - import mock # python < 3.3 - @pytest.fixture(autouse=True) def _patch_rq_get_server_version(monkeypatch): diff --git a/tests/integrations/sqlalchemy/test_sqlalchemy.py b/tests/integrations/sqlalchemy/test_sqlalchemy.py index cfcf139616..e31fb73884 100644 --- a/tests/integrations/sqlalchemy/test_sqlalchemy.py +++ b/tests/integrations/sqlalchemy/test_sqlalchemy.py @@ -1,4 +1,3 @@ -import sys import pytest from sqlalchemy import Column, ForeignKey, Integer, String, create_engine @@ -72,9 +71,6 @@ class Address(Base): ] -@pytest.mark.skipif( - sys.version_info < (3,), reason="This sqla usage seems to be broken on Py2" -) def test_transactions(sentry_init, capture_events, render_span_tree): sentry_init( integrations=[SqlalchemyIntegration()], diff --git a/tests/integrations/starlette/test_starlette.py b/tests/integrations/starlette/test_starlette.py index 329048e23c..d717cda3a9 100644 --- a/tests/integrations/starlette/test_starlette.py +++ b/tests/integrations/starlette/test_starlette.py @@ -6,23 +6,17 @@ import os import re import threading +from unittest import mock import pytest -from sentry_sdk import last_event_id, capture_exception +from sentry_sdk import last_event_id, capture_exception, capture_message from sentry_sdk.integrations.asgi import SentryAsgiMiddleware -from sentry_sdk.utils import parse_version - -try: - from unittest import mock # python 3.3 and above -except ImportError: - import mock # python < 3.3 - -from sentry_sdk import capture_message from sentry_sdk.integrations.starlette import ( StarletteIntegration, StarletteRequestExtractor, ) +from sentry_sdk.utils import parse_version import starlette from starlette.authentication import ( diff --git a/tests/integrations/stdlib/test_httplib.py b/tests/integrations/stdlib/test_httplib.py index d50bf42e21..f6cee2f027 100644 --- a/tests/integrations/stdlib/test_httplib.py +++ b/tests/integrations/stdlib/test_httplib.py @@ -1,27 +1,10 @@ import random +from http.client import HTTPConnection, HTTPSConnection +from urllib.request import urlopen +from unittest import mock import pytest -try: - # py3 - from urllib.request import urlopen -except ImportError: - # py2 - from urllib import urlopen - -try: - # py2 - from httplib import HTTPConnection, HTTPSConnection -except ImportError: - # py3 - from http.client import HTTPConnection, HTTPSConnection - -try: - from unittest import mock # python 3.3 and above -except ImportError: - import mock # python < 3.3 - - from sentry_sdk import capture_message, start_transaction from sentry_sdk.consts import MATCH_ALL, SPANDATA from sentry_sdk.tracing import Transaction diff --git a/tests/integrations/threading/test_threading.py b/tests/integrations/threading/test_threading.py index 555694133e..d31cb7c216 100644 --- a/tests/integrations/threading/test_threading.py +++ b/tests/integrations/threading/test_threading.py @@ -1,12 +1,7 @@ import gc -import sys +from concurrent import futures from threading import Thread -try: - from concurrent import futures -except ImportError: - futures = None - import pytest import sentry_sdk @@ -79,10 +74,6 @@ def stage2(): assert "stage1" not in event.get("tags", {}) -@pytest.mark.skipif( - futures is None, - reason="ThreadPool was added in 3.2", -) @pytest.mark.parametrize("propagate_hub", (True, False)) def test_propagates_threadpool_hub(sentry_init, capture_events, propagate_hub): sentry_init( @@ -163,7 +154,6 @@ def run(self): assert exception["type"] == "ZeroDivisionError" -@pytest.mark.skipif(sys.version_info < (3, 2), reason="no __qualname__ in older python") def test_wrapper_attributes(sentry_init): sentry_init(default_integrations=False, integrations=[ThreadingIntegration()]) @@ -184,24 +174,3 @@ def target(): assert Thread.run.__qualname__ == original_run.__qualname__ assert t.run.__name__ == "run" assert t.run.__qualname__ == original_run.__qualname__ - - -@pytest.mark.skipif( - sys.version_info > (2, 7), - reason="simpler test for py2.7 without py3 only __qualname__", -) -def test_wrapper_attributes_no_qualname(sentry_init): - sentry_init(default_integrations=False, integrations=[ThreadingIntegration()]) - - def target(): - assert t.run.__name__ == "run" - - t = Thread(target=target) - t.start() - t.join() - - assert Thread.start.__name__ == "start" - assert t.start.__name__ == "start" - - assert Thread.run.__name__ == "run" - assert t.run.__name__ == "run" diff --git a/tests/integrations/wsgi/test_wsgi.py b/tests/integrations/wsgi/test_wsgi.py index 0b76bf6887..d0b0186990 100644 --- a/tests/integrations/wsgi/test_wsgi.py +++ b/tests/integrations/wsgi/test_wsgi.py @@ -1,18 +1,13 @@ import sys - -from werkzeug.test import Client +from collections import Counter +from unittest import mock import pytest +from werkzeug.test import Client import sentry_sdk from sentry_sdk import capture_message from sentry_sdk.integrations.wsgi import SentryWsgiMiddleware -from collections import Counter - -try: - from unittest import mock # python 3.3 and above -except ImportError: - import mock # python < 3.3 @pytest.fixture diff --git a/tests/test_api.py b/tests/test_api.py index 1adb9095f0..9803f08146 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -1,3 +1,5 @@ +from unittest import mock + from sentry_sdk import ( configure_scope, continue_trace, @@ -8,11 +10,6 @@ ) from sentry_sdk.hub import Hub -try: - from unittest import mock # python 3.3 and above -except ImportError: - import mock # python < 3.3 - def test_get_current_span(): fake_hub = mock.MagicMock() diff --git a/tests/test_client.py b/tests/test_client.py index b1430ef16d..732b256ae1 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -1,11 +1,13 @@ import os import json -import pytest import subprocess import sys import time - from textwrap import dedent +from unittest import mock + +import pytest + from sentry_sdk import ( Hub, Client, @@ -20,7 +22,6 @@ from sentry_sdk.integrations.executing import ExecutingIntegration from sentry_sdk.transport import Transport from sentry_sdk._compat import reraise, text_type, PY2 -from sentry_sdk.utils import HAS_CHAINED_EXCEPTIONS from sentry_sdk.utils import logger from sentry_sdk.serializer import MAX_DATABAG_BREADTH from sentry_sdk.consts import DEFAULT_MAX_BREADCRUMBS, DEFAULT_MAX_VALUE_LENGTH @@ -31,11 +32,6 @@ from typing import Any, Optional, Union from sentry_sdk._types import Event -try: - from unittest import mock # python 3.3 and above -except ImportError: - import mock # python < 3.3 - if PY2: # Importing ABCs from collections is deprecated, and will stop working in 3.8 # https://github.com/python/cpython/blob/master/Lib/collections/__init__.py#L49 @@ -807,7 +803,6 @@ def inner(): assert len(json.dumps(event)) < 10000 -@pytest.mark.skipif(not HAS_CHAINED_EXCEPTIONS, reason="Only works on 3.3+") def test_chained_exceptions(sentry_init, capture_events): sentry_init() events = capture_events() diff --git a/tests/test_crons.py b/tests/test_crons.py index 39d02a5d47..5c9ae5fe7d 100644 --- a/tests/test_crons.py +++ b/tests/test_crons.py @@ -1,15 +1,10 @@ import pytest import uuid +from unittest import mock import sentry_sdk -from sentry_sdk.crons import capture_checkin - from sentry_sdk import Hub, configure_scope, set_level - -try: - from unittest import mock # python 3.3 and above -except ImportError: - import mock # python < 3.3 +from sentry_sdk.crons import capture_checkin @sentry_sdk.monitor(monitor_slug="abc123") diff --git a/tests/test_metrics.py b/tests/test_metrics.py index c3d3978121..1f4a2589f0 100644 --- a/tests/test_metrics.py +++ b/tests/test_metrics.py @@ -1,16 +1,12 @@ import sys import time import linecache +from unittest import mock from sentry_sdk import Hub, metrics, push_scope, start_transaction from sentry_sdk.tracing import TRANSACTION_SOURCE_ROUTE from sentry_sdk.envelope import parse_json -try: - from unittest import mock # python 3.3 and above -except ImportError: - import mock # python < 3.3 - def parse_metrics(bytes): rv = [] diff --git a/tests/test_monitor.py b/tests/test_monitor.py index 42d600ebbb..088dd9654a 100644 --- a/tests/test_monitor.py +++ b/tests/test_monitor.py @@ -1,13 +1,9 @@ import random +from unittest import mock from sentry_sdk import Hub, start_transaction from sentry_sdk.transport import Transport -try: - from unittest import mock # python 3.3 and above -except ImportError: - import mock # python < 3.3 - class HealthyTestTransport(Transport): def _send_event(self, event): diff --git a/tests/test_profiler.py b/tests/test_profiler.py index 866349792a..c1fcb0fd02 100644 --- a/tests/test_profiler.py +++ b/tests/test_profiler.py @@ -3,10 +3,11 @@ import sys import threading import time +from collections import defaultdict +from unittest import mock import pytest -from collections import defaultdict from sentry_sdk import start_transaction from sentry_sdk.profiler import ( GeventScheduler, @@ -24,23 +25,12 @@ from sentry_sdk._lru_cache import LRUCache from sentry_sdk._queue import Queue -try: - from unittest import mock # python 3.3 and above -except ImportError: - import mock # python < 3.3 - try: import gevent except ImportError: gevent = None -def requires_python_version(major, minor, reason=None): - if reason is None: - reason = "Requires Python {}.{}".format(major, minor) - return pytest.mark.skipif(sys.version_info < (major, minor), reason=reason) - - requires_gevent = pytest.mark.skipif(gevent is None, reason="gevent not enabled") @@ -59,7 +49,6 @@ def experimental_options(mode=None, sample_rate=None): } -@requires_python_version(3, 3) @pytest.mark.parametrize( "mode", [ @@ -82,7 +71,6 @@ def test_profiler_invalid_mode(mode, make_options, teardown_profiling): setup_profiler(make_options(mode)) -@requires_python_version(3, 3) @pytest.mark.parametrize( "mode", [ @@ -103,7 +91,6 @@ def test_profiler_valid_mode(mode, make_options, teardown_profiling): setup_profiler(make_options(mode)) -@requires_python_version(3, 3) @pytest.mark.parametrize( "make_options", [ @@ -118,7 +105,6 @@ def test_profiler_setup_twice(make_options, teardown_profiling): assert not setup_profiler(make_options()) -@requires_python_version(3, 3) @pytest.mark.parametrize( "mode", [ @@ -184,7 +170,6 @@ def test_profiles_sample_rate( assert reports == [("sample_rate", "profile")] -@requires_python_version(3, 3) @pytest.mark.parametrize( "mode", [ @@ -252,7 +237,6 @@ def test_profiles_sampler( assert reports == [("sample_rate", "profile")] -@requires_python_version(3, 3) def test_minimum_unique_samples_required( sentry_init, capture_envelopes, @@ -282,7 +266,6 @@ def test_minimum_unique_samples_required( assert reports == [("insufficient_data", "profile")] -@requires_python_version(3, 3) def test_profile_captured( sentry_init, capture_envelopes, @@ -372,7 +355,6 @@ def static_method(): return inspect.currentframe() -@requires_python_version(3, 3) @pytest.mark.parametrize( ("frame", "frame_name"), [ @@ -452,7 +434,6 @@ def test_get_frame_name(frame, frame_name): assert get_frame_name(frame) == frame_name -@requires_python_version(3, 3) @pytest.mark.parametrize( ("get_frame", "function"), [ @@ -480,7 +461,6 @@ def test_extract_frame(get_frame, function): assert isinstance(extracted_frame["lineno"], int) -@requires_python_version(3, 3) @pytest.mark.parametrize( ("depth", "max_stack_depth", "actual_depth"), [ @@ -522,7 +502,6 @@ def test_extract_stack_with_max_depth(depth, max_stack_depth, actual_depth): assert frames[actual_depth]["function"] == "", actual_depth -@requires_python_version(3, 3) @pytest.mark.parametrize( ("frame", "depth"), [(get_frame(depth=1), len(inspect.stack()))], @@ -545,7 +524,6 @@ def test_extract_stack_with_cache(frame, depth): assert frame1 is frame2, i -@requires_python_version(3, 3) def test_get_current_thread_id_explicit_thread(): results = Queue(maxsize=1) @@ -567,7 +545,6 @@ def target2(): assert thread1.ident == results.get(timeout=1) -@requires_python_version(3, 3) @requires_gevent def test_get_current_thread_id_gevent_in_thread(): results = Queue(maxsize=1) @@ -583,7 +560,6 @@ def target(): assert thread.ident == results.get(timeout=1) -@requires_python_version(3, 3) def test_get_current_thread_id_running_thread(): results = Queue(maxsize=1) @@ -596,7 +572,6 @@ def target(): assert thread.ident == results.get(timeout=1) -@requires_python_version(3, 3) def test_get_current_thread_id_main_thread(): results = Queue(maxsize=1) @@ -617,7 +592,6 @@ def get_scheduler_threads(scheduler): return [thread for thread in threading.enumerate() if thread.name == scheduler.name] -@requires_python_version(3, 3) @pytest.mark.parametrize( ("scheduler_class",), [ @@ -661,7 +635,6 @@ def test_thread_scheduler_single_background_thread(scheduler_class): assert len(get_scheduler_threads(scheduler)) == 0 -@requires_python_version(3, 3) @pytest.mark.parametrize( ("scheduler_class",), [ @@ -706,7 +679,6 @@ def test_thread_scheduler_no_thread_on_shutdown(scheduler_class): assert len(get_scheduler_threads(scheduler)) == 0 -@requires_python_version(3, 3) @pytest.mark.parametrize( ("scheduler_class",), [ @@ -784,7 +756,6 @@ def ensure_running(self): ] -@requires_python_version(3, 3) @pytest.mark.parametrize( ("samples", "expected"), [ diff --git a/tests/test_scope.py b/tests/test_scope.py index 8bdd46e02f..88022e3920 100644 --- a/tests/test_scope.py +++ b/tests/test_scope.py @@ -1,14 +1,11 @@ import copy import os import pytest +from unittest import mock + from sentry_sdk import capture_exception from sentry_sdk.scope import Scope -try: - from unittest import mock # python 3.3 and above -except ImportError: - import mock # python < 3.3 - def test_copying(): s1 = Scope() diff --git a/tests/test_serializer.py b/tests/test_serializer.py index 9925229888..a3ead112a7 100644 --- a/tests/test_serializer.py +++ b/tests/test_serializer.py @@ -1,5 +1,5 @@ import re -import sys + import pytest from sentry_sdk.serializer import MAX_DATABAG_BREADTH, MAX_DATABAG_DEPTH, serialize @@ -64,7 +64,6 @@ def test_bytes_serialization_decode(message_normalizer): assert result == "abc123\ufffd\U0001f355" -@pytest.mark.xfail(sys.version_info < (3,), reason="Known safe_repr bugs in Py2.7") def test_bytes_serialization_repr(message_normalizer): binary = b"abc123\x80\xf0\x9f\x8d\x95" result = message_normalizer(binary, should_repr_strings=True) @@ -77,7 +76,6 @@ def test_bytearray_serialization_decode(message_normalizer): assert result == "abc123\ufffd\U0001f355" -@pytest.mark.xfail(sys.version_info < (3,), reason="Known safe_repr bugs in Py2.7") def test_bytearray_serialization_repr(message_normalizer): binary = bytearray(b"abc123\x80\xf0\x9f\x8d\x95") result = message_normalizer(binary, should_repr_strings=True) diff --git a/tests/test_sessions.py b/tests/test_sessions.py index 311aa53966..91ce9cc58b 100644 --- a/tests/test_sessions.py +++ b/tests/test_sessions.py @@ -1,13 +1,9 @@ -import sentry_sdk +from unittest import mock +import sentry_sdk from sentry_sdk import Hub from sentry_sdk.sessions import auto_session_tracking -try: - from unittest import mock # python 3.3 and above -except ImportError: - import mock # python < 3.3 - def sorted_aggregates(item): aggregates = item["aggregates"] diff --git a/tests/test_transport.py b/tests/test_transport.py index 996ab37969..43c6e710f4 100644 --- a/tests/test_transport.py +++ b/tests/test_transport.py @@ -2,14 +2,13 @@ import pickle import gzip import io - +from collections import namedtuple from datetime import datetime, timedelta +from unittest import mock import pytest -from collections import namedtuple -from werkzeug.wrappers import Request, Response - from pytest_localserver.http import WSGIServer +from werkzeug.wrappers import Request, Response from sentry_sdk import Hub, Client, add_breadcrumb, capture_message, Scope from sentry_sdk._compat import datetime_utcnow @@ -17,10 +16,6 @@ from sentry_sdk.envelope import Envelope, parse_json from sentry_sdk.integrations.logging import LoggingIntegration -try: - from unittest import mock # python 3.3 and above -except ImportError: - import mock # python < 3.3 CapturedData = namedtuple("CapturedData", ["path", "event", "envelope", "compressed"]) diff --git a/tests/test_utils.py b/tests/test_utils.py index 71657f75c7..e9e76076bd 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,7 +1,9 @@ import pytest import re import sys +from unittest import mock +import sentry_sdk from sentry_sdk.utils import ( Components, Dsn, @@ -20,20 +22,6 @@ _get_installed_modules, ) -import sentry_sdk - -try: - from unittest import mock # python 3.3 and above -except ImportError: - import mock # python < 3.3 - -try: - # Python 3 - FileNotFoundError -except NameError: - # Python 2 - FileNotFoundError = IOError - def _normalize_distribution_name(name): # type: (str) -> str diff --git a/tests/tracing/test_decorator_sync.py b/tests/tracing/test_decorator_sync.py index 6d7be8b8f9..e48b2a92ac 100644 --- a/tests/tracing/test_decorator_sync.py +++ b/tests/tracing/test_decorator_sync.py @@ -1,3 +1,5 @@ +from unittest import mock + from sentry_sdk._compat import PY2 if PY2: @@ -9,11 +11,6 @@ from tests.conftest import patch_start_tracing_child -try: - from unittest import mock # python 3.3 and above -except ImportError: - import mock # python < 3.3 - def my_example_function(): return "return_of_sync_function" diff --git a/tests/tracing/test_http_headers.py b/tests/tracing/test_http_headers.py index 443bb163e8..6a8467101e 100644 --- a/tests/tracing/test_http_headers.py +++ b/tests/tracing/test_http_headers.py @@ -1,15 +1,11 @@ +from unittest import mock + import pytest from sentry_sdk.tracing import Transaction from sentry_sdk.tracing_utils import extract_sentrytrace_data -try: - from unittest import mock # python 3.3 and above -except ImportError: - import mock # python < 3.3 - - @pytest.mark.parametrize("sampled", [True, False, None]) def test_to_traceparent(sampled): transaction = Transaction( diff --git a/tests/tracing/test_misc.py b/tests/tracing/test_misc.py index 3668f1b3a8..c269ae9971 100644 --- a/tests/tracing/test_misc.py +++ b/tests/tracing/test_misc.py @@ -2,6 +2,8 @@ import gc import uuid import os +from unittest import mock +from unittest.mock import MagicMock import sentry_sdk from sentry_sdk import Hub, start_span, start_transaction, set_measurement, push_scope @@ -10,13 +12,6 @@ from sentry_sdk.tracing_utils import should_propagate_trace from sentry_sdk.utils import Dsn -try: - from unittest import mock # python 3.3 and above - from unittest.mock import MagicMock -except ImportError: - import mock # python < 3.3 - from mock import MagicMock - def test_span_trimming(sentry_init, capture_events): sentry_init(traces_sample_rate=1.0, _experiments={"max_spans": 3}) diff --git a/tests/tracing/test_sampling.py b/tests/tracing/test_sampling.py index 6101a948ef..b048149f35 100644 --- a/tests/tracing/test_sampling.py +++ b/tests/tracing/test_sampling.py @@ -1,4 +1,5 @@ import random +from unittest import mock import pytest @@ -6,11 +7,6 @@ from sentry_sdk.tracing import Transaction from sentry_sdk.utils import logger -try: - from unittest import mock # python 3.3 and above -except ImportError: - import mock # python < 3.3 - def test_sampling_decided_only_for_transactions(sentry_init, capture_events): sentry_init(traces_sample_rate=0.5) diff --git a/tests/utils/test_transaction.py b/tests/utils/test_transaction.py index bfb87f4c29..96145e092a 100644 --- a/tests/utils/test_transaction.py +++ b/tests/utils/test_transaction.py @@ -1,15 +1,7 @@ -import sys -from functools import partial - -import pytest +from functools import partial, partialmethod from sentry_sdk.utils import transaction_from_function -try: - from functools import partialmethod -except ImportError: - pass - class MyClass: def myfunc(self): @@ -48,7 +40,6 @@ def test_transaction_from_function(): ) -@pytest.mark.skipif(sys.version_info < (3, 4), reason="Require python 3.4 or higher") def test_transaction_from_function_partialmethod(): x = transaction_from_function From 8644764fe5ee30148cee063b53fec7f80994fd61 Mon Sep 17 00:00:00 2001 From: Ivana Kellyerova Date: Tue, 16 Jan 2024 17:37:20 +0100 Subject: [PATCH 2/5] more compat --- tests/integrations/logging/test_logging.py | 6 ++---- tests/integrations/pure_eval/test_pure_eval.py | 6 +----- tests/integrations/wsgi/test_wsgi.py | 4 ---- tests/test_profiler.py | 2 +- tests/tracing/test_decorator_async_py3.py | 5 +---- tests/utils/test_general.py | 4 ---- 6 files changed, 5 insertions(+), 22 deletions(-) diff --git a/tests/integrations/logging/test_logging.py b/tests/integrations/logging/test_logging.py index 6309e8dcf2..02eb26a04d 100644 --- a/tests/integrations/logging/test_logging.py +++ b/tests/integrations/logging/test_logging.py @@ -1,9 +1,8 @@ -import sys - -import pytest import logging import warnings +import pytest + from sentry_sdk.integrations.logging import LoggingIntegration, ignore_logger other_logger = logging.getLogger("testfoo") @@ -78,7 +77,6 @@ def test_logging_extra_data_integer_keys(sentry_init, capture_events): assert event["extra"] == {"1": 1} -@pytest.mark.xfail(sys.version_info[:2] == (3, 4), reason="buggy logging module") def test_logging_stack(sentry_init, capture_events): sentry_init(integrations=[LoggingIntegration()], default_integrations=False) events = capture_events() diff --git a/tests/integrations/pure_eval/test_pure_eval.py b/tests/integrations/pure_eval/test_pure_eval.py index 2d1a92026e..497a8768d0 100644 --- a/tests/integrations/pure_eval/test_pure_eval.py +++ b/tests/integrations/pure_eval/test_pure_eval.py @@ -1,4 +1,3 @@ -import sys from types import SimpleNamespace import pytest @@ -64,10 +63,7 @@ def foo(): "u", "y", ] - if sys.version_info[:2] == (3, 5): - assert frame_vars.keys() == set(expected_keys) - else: - assert list(frame_vars.keys()) == expected_keys + assert list(frame_vars.keys()) == expected_keys assert frame_vars["namespace.d"] == {"1": "2"} assert frame_vars["namespace.d[1]"] == "2" else: diff --git a/tests/integrations/wsgi/test_wsgi.py b/tests/integrations/wsgi/test_wsgi.py index d0b0186990..7d55482343 100644 --- a/tests/integrations/wsgi/test_wsgi.py +++ b/tests/integrations/wsgi/test_wsgi.py @@ -1,4 +1,3 @@ -import sys from collections import Counter from unittest import mock @@ -413,9 +412,6 @@ def sample_app(environ, start_response): assert len(session_aggregates) == 1 -@pytest.mark.skipif( - sys.version_info < (3, 3), reason="Profiling is only supported in Python >= 3.3" -) @mock.patch("sentry_sdk.profiler.PROFILE_MINIMUM_SAMPLES", 0) def test_profile_sent( sentry_init, diff --git a/tests/test_profiler.py b/tests/test_profiler.py index c1fcb0fd02..d006900144 100644 --- a/tests/test_profiler.py +++ b/tests/test_profiler.py @@ -580,7 +580,7 @@ def target(): with mock.patch("threading.current_thread", side_effect=[None]): results.put(get_current_thread_id()) - thread_id = threading.main_thread().ident if sys.version_info >= (3, 4) else None + thread_id = threading.main_thread().ident thread = threading.Thread(target=target) thread.start() diff --git a/tests/tracing/test_decorator_async_py3.py b/tests/tracing/test_decorator_async_py3.py index 401180ad39..5e4b6bdaf0 100644 --- a/tests/tracing/test_decorator_async_py3.py +++ b/tests/tracing/test_decorator_async_py3.py @@ -1,6 +1,6 @@ from unittest import mock + import pytest -import sys from tests.conftest import patch_start_tracing_child @@ -9,9 +9,6 @@ ) from sentry_sdk.utils import logger -if sys.version_info < (3, 6): - pytest.skip("Async decorator only works on Python 3.6+", allow_module_level=True) - async def my_async_example_function(): return "return_of_async_function" diff --git a/tests/utils/test_general.py b/tests/utils/test_general.py index b655307daa..6d5d9e1950 100644 --- a/tests/utils/test_general.py +++ b/tests/utils/test_general.py @@ -39,10 +39,6 @@ def test_safe_repr_regressions(): assert "лошадь" in safe_repr("лошадь") -@pytest.mark.xfail( - sys.version_info < (3,), - reason="Fixing this in Python 2 would break other behaviors", -) @pytest.mark.parametrize("prefix", ("", "abcd", "лошадь")) @pytest.mark.parametrize("character", "\x00\x07\x1b\n") def test_safe_repr_non_printable(prefix, character): From 837be0fa0be97f5e126e964ff47b178e5d06994f Mon Sep 17 00:00:00 2001 From: Ivana Kellyerova Date: Thu, 18 Jan 2024 12:25:38 +0100 Subject: [PATCH 3/5] wip --- .../test_cloud_resource_context.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/tests/integrations/cloud_resource_context/test_cloud_resource_context.py b/tests/integrations/cloud_resource_context/test_cloud_resource_context.py index 065db0d09e..6b3fadf4c4 100644 --- a/tests/integrations/cloud_resource_context/test_cloud_resource_context.py +++ b/tests/integrations/cloud_resource_context/test_cloud_resource_context.py @@ -1,5 +1,5 @@ import json -from unittest import mock # python 3.3 and above +from unittest import mock from unittest.mock import MagicMock import pytest @@ -27,16 +27,11 @@ "version": "2017-09-30", } -try: - # Python 3 - AWS_EC2_EXAMPLE_IMDSv2_PAYLOAD_BYTES = bytes( - json.dumps(AWS_EC2_EXAMPLE_IMDSv2_PAYLOAD), "utf-8" - ) -except TypeError: - # Python 2 - AWS_EC2_EXAMPLE_IMDSv2_PAYLOAD_BYTES = bytes( - json.dumps(AWS_EC2_EXAMPLE_IMDSv2_PAYLOAD) - ).encode("utf-8") + +AWS_EC2_EXAMPLE_IMDSv2_PAYLOAD_BYTES = bytes( + json.dumps(AWS_EC2_EXAMPLE_IMDSv2_PAYLOAD), "utf-8" +) + GCP_GCE_EXAMPLE_METADATA_PLAYLOAD = { "instance": { From 0c3c83b4f47c90a04023512d18b36dae735c975b Mon Sep 17 00:00:00 2001 From: Ivana Kellyerova Date: Fri, 19 Jan 2024 16:17:54 +0100 Subject: [PATCH 4/5] rename *py3.py files --- .../integrations/asyncio/{test_asyncio_py3.py => test_asyncio.py} | 0 .../graphene/{test_graphene_py3.py => test_graphene.py} | 0 .../strawberry/{test_strawberry_py3.py => test_strawberry.py} | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename tests/integrations/asyncio/{test_asyncio_py3.py => test_asyncio.py} (100%) rename tests/integrations/graphene/{test_graphene_py3.py => test_graphene.py} (100%) rename tests/integrations/strawberry/{test_strawberry_py3.py => test_strawberry.py} (100%) diff --git a/tests/integrations/asyncio/test_asyncio_py3.py b/tests/integrations/asyncio/test_asyncio.py similarity index 100% rename from tests/integrations/asyncio/test_asyncio_py3.py rename to tests/integrations/asyncio/test_asyncio.py diff --git a/tests/integrations/graphene/test_graphene_py3.py b/tests/integrations/graphene/test_graphene.py similarity index 100% rename from tests/integrations/graphene/test_graphene_py3.py rename to tests/integrations/graphene/test_graphene.py diff --git a/tests/integrations/strawberry/test_strawberry_py3.py b/tests/integrations/strawberry/test_strawberry.py similarity index 100% rename from tests/integrations/strawberry/test_strawberry_py3.py rename to tests/integrations/strawberry/test_strawberry.py From aebf7a58ca13d6579dcee465ea5e87e4df38b776 Mon Sep 17 00:00:00 2001 From: Ivana Kellyerova Date: Mon, 22 Jan 2024 12:19:53 +0100 Subject: [PATCH 5/5] remove missing import compat --- tests/integrations/rediscluster/test_rediscluster.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/tests/integrations/rediscluster/test_rediscluster.py b/tests/integrations/rediscluster/test_rediscluster.py index 14d831a647..b1091337b8 100644 --- a/tests/integrations/rediscluster/test_rediscluster.py +++ b/tests/integrations/rediscluster/test_rediscluster.py @@ -1,17 +1,13 @@ +from unittest import mock + import pytest +import rediscluster from sentry_sdk import capture_message from sentry_sdk.api import start_transaction from sentry_sdk.consts import SPANDATA from sentry_sdk.integrations.redis import RedisIntegration -try: - from unittest import mock -except ImportError: - import mock - -import rediscluster - MOCK_CONNECTION_POOL = mock.MagicMock() MOCK_CONNECTION_POOL.connection_kwargs = {