Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Fix using unittest.mock whenever available #1926

Merged
merged 15 commits into from Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion test-requirements.txt
@@ -1,5 +1,5 @@
pip # always use newest pip
mock # for testing under python < 3.3
mock ; python_version<'3.3'
pytest<7
pytest-cov==2.8.1
pytest-forked<=1.4.0
Expand Down
@@ -1,8 +1,13 @@
import json

import pytest
import mock
from mock import MagicMock

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,
Expand Down
8 changes: 6 additions & 2 deletions tests/integrations/opentelemetry/test_propagator.py
@@ -1,5 +1,9 @@
from mock import MagicMock
import mock
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 opentelemetry.context import get_current
from opentelemetry.trace.propagation import get_current_span
Expand Down
10 changes: 8 additions & 2 deletions tests/integrations/opentelemetry/test_span_processor.py
@@ -1,7 +1,13 @@
from datetime import datetime
from mock import MagicMock
import mock
import time

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

from sentry_sdk.integrations.opentelemetry.span_processor import (
SentrySpanProcessor,
link_trace_context_to_error_event,
Expand Down
3 changes: 2 additions & 1 deletion tests/tracing/test_misc.py
@@ -1,4 +1,3 @@
from mock import MagicMock
import pytest
import gc
import uuid
Expand All @@ -12,8 +11,10 @@

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):
Expand Down