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
3 changes: 0 additions & 3 deletions requirements-base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@ phabricator==0.7.0
# sentry.utils.pytest and sentry.testutils are moved to tests/
selenium==3.141.0
sqlparse==0.2.4
# We're still using mock in Python 3.6 because it contains a fix to Python issue37972.
# We should be able to fully swap it out for stdlib once we're on 3.8.
mock==4.0.3

# this is already a transitive dependency via structlog, and we started
# implicitly relying on it because of that. Can probably be removed with 3.8
Expand Down
4 changes: 2 additions & 2 deletions src/sentry/testutils/cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import time
from contextlib import contextmanager
from datetime import datetime
from unittest import mock
from unittest.mock import patch
from urllib.parse import urlencode
from uuid import uuid4

Expand Down Expand Up @@ -84,8 +86,6 @@
from sentry.testutils.helpers.datetime import iso_format
from sentry.utils import json
from sentry.utils.auth import SSO_SESSION_KEY
from sentry.utils.compat import mock
from sentry.utils.compat.mock import patch
from sentry.utils.pytest.selenium import Browser
from sentry.utils.retries import TimedRetryPolicy
from sentry.utils.snuba import _snuba_pool
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/testutils/helpers/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import logging
from collections.abc import Mapping
from contextlib import contextmanager
from unittest.mock import patch

import sentry.features
from sentry.features.exceptions import FeatureNotRegistered
from sentry.utils.compat.mock import patch

logger = logging.getLogger(__name__)

Expand Down
3 changes: 1 addition & 2 deletions src/sentry/testutils/helpers/options.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
__all__ = ["override_options"]

from contextlib import contextmanager
from unittest.mock import patch

from django.test.utils import override_settings

from sentry.utils.compat.mock import patch


@contextmanager
def override_options(options):
Expand Down
3 changes: 1 addition & 2 deletions src/sentry/testutils/helpers/task_runner.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
__all__ = ["TaskRunner"]

from contextlib import contextmanager
from unittest.mock import patch

from celery import current_app
from django.conf import settings

from sentry.utils.compat.mock import patch


@contextmanager
def TaskRunner():
Expand Down
4 changes: 0 additions & 4 deletions src/sentry/utils/compat/mock.py

This file was deleted.

2 changes: 1 addition & 1 deletion src/sentry/utils/pytest/sentry.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import os
from hashlib import md5
from unittest import mock

from django.conf import settings
from sentry_sdk import Hub

from sentry.utils.compat import mock
from sentry.utils.warnings import UnsupportedBackend

TEST_ROOT = os.path.normpath(
Expand Down
3 changes: 2 additions & 1 deletion tests/acceptance/test_create_project.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from unittest.mock import patch

from sentry.models import Project
from sentry.testutils import AcceptanceTestCase
from sentry.utils.compat.mock import patch


class CreateProjectTest(AcceptanceTestCase):
Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/test_issue_details.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from datetime import datetime, timedelta
from unittest.mock import patch

import pytz
from django.utils import timezone

from sentry.testutils import AcceptanceTestCase, SnubaTestCase
from sentry.utils.compat.mock import patch
from sentry.utils.samples import load_data
from tests.acceptance.page_objects.issue_details import IssueDetailsPage

Expand Down
3 changes: 2 additions & 1 deletion tests/acceptance/test_onboarding.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from unittest import mock

from selenium.common.exceptions import TimeoutException

from sentry.models import Project
from sentry.testutils import AcceptanceTestCase
from sentry.utils.compat import mock
from sentry.utils.retries import TimedRetryPolicy


Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/test_organization_events_v2.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import copy
from datetime import timedelta
from unittest.mock import patch
from urllib.parse import urlencode

import pytest
Expand All @@ -9,7 +10,6 @@
from sentry.discover.models import DiscoverSavedQuery
from sentry.testutils import AcceptanceTestCase, SnubaTestCase
from sentry.testutils.helpers.datetime import before_now, iso_format, timestamp_format
from sentry.utils.compat.mock import patch
from sentry.utils.samples import load_data

FEATURE_NAMES = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from datetime import datetime
from unittest.mock import patch

import pytest
import pytz
from django.utils import timezone

from sentry.testutils import AcceptanceTestCase, SnubaTestCase
from sentry.testutils.helpers.datetime import before_now, iso_format
from sentry.utils.compat.mock import patch
from tests.acceptance.page_objects.issue_details import IssueDetailsPage
from tests.acceptance.page_objects.issue_list import IssueListPage

Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/test_organization_group_index.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from datetime import datetime
from unittest.mock import patch

import pytz
from django.utils import timezone
Expand All @@ -7,7 +8,6 @@
from sentry.models.groupinbox import add_group_to_inbox
from sentry.testutils import AcceptanceTestCase, SnubaTestCase
from sentry.testutils.helpers.datetime import before_now, iso_format
from sentry.utils.compat.mock import patch
from tests.acceptance.page_objects.issue_list import IssueListPage

event_time = before_now(days=3).replace(tzinfo=pytz.utc)
Expand Down
3 changes: 2 additions & 1 deletion tests/acceptance/test_organization_rate_limits.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from unittest.mock import Mock, patch

from django.utils import timezone

from sentry.testutils import AcceptanceTestCase
from sentry.utils.compat.mock import Mock, patch


class OrganizationRateLimitsTest(AcceptanceTestCase):
Expand Down
3 changes: 2 additions & 1 deletion tests/acceptance/test_performance_landing.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from unittest.mock import patch

import pytz
from django.db.models import F

from sentry.models import Project
from sentry.testutils import AcceptanceTestCase, SnubaTestCase
from sentry.testutils.helpers.datetime import before_now
from sentry.utils.compat.mock import patch
from sentry.utils.samples import load_data

from .page_objects.base import BasePage
Expand Down
3 changes: 2 additions & 1 deletion tests/acceptance/test_performance_overview.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from unittest.mock import patch

import pytz
from django.db.models import F

from sentry.models import Project
from sentry.testutils import AcceptanceTestCase, SnubaTestCase
from sentry.testutils.helpers.datetime import before_now
from sentry.utils.compat.mock import patch
from sentry.utils.samples import load_data

from .page_objects.base import BasePage
Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/test_performance_summary.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from unittest.mock import patch
from urllib.parse import urlencode

import pytz

from sentry.models import AssistantActivity
from sentry.testutils import AcceptanceTestCase, SnubaTestCase
from sentry.testutils.helpers.datetime import before_now, iso_format
from sentry.utils.compat.mock import patch
from sentry.utils.samples import load_data

from .page_objects.transaction_summary import TransactionSummaryPage
Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/test_performance_trace_detail.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from datetime import timedelta
from unittest.mock import patch
from uuid import uuid4

import pytz

from sentry.testutils import AcceptanceTestCase, SnubaTestCase
from sentry.testutils.helpers.datetime import before_now, iso_format
from sentry.utils.compat.mock import patch
from sentry.utils.samples import load_data

FEATURE_NAMES = ["organizations:performance-view"]
Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/test_performance_trends.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from unittest.mock import patch
from urllib.parse import urlencode

import pytz
Expand All @@ -6,7 +7,6 @@
from sentry.models import Project
from sentry.testutils import AcceptanceTestCase, SnubaTestCase
from sentry.testutils.helpers.datetime import before_now, iso_format
from sentry.utils.compat.mock import patch
from sentry.utils.samples import load_data

from .page_objects.base import BasePage
Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/test_performance_vital_detail.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from unittest.mock import patch
from urllib.parse import urlencode

import pytz
Expand All @@ -6,7 +7,6 @@
from sentry.models import Project
from sentry.testutils import AcceptanceTestCase, SnubaTestCase
from sentry.testutils.helpers.datetime import before_now
from sentry.utils.compat.mock import patch
from sentry.utils.samples import load_data

from .page_objects.base import BasePage
Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/test_project_tags_settings.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from datetime import datetime
from unittest.mock import patch

import pytz

from sentry.testutils import AcceptanceTestCase, SnubaTestCase
from sentry.testutils.helpers.datetime import before_now, iso_format
from sentry.utils.compat.mock import patch

event_time = before_now(days=3).replace(tzinfo=pytz.utc)
current_time = datetime.utcnow().replace(tzinfo=pytz.utc)
Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/test_transaction_comparison.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import copy
from datetime import datetime, timedelta
from unittest.mock import patch

import pytz

from sentry.testutils import AcceptanceTestCase, SnubaTestCase
from sentry.testutils.helpers.datetime import before_now, timestamp_format
from sentry.utils.compat.mock import patch
from tests.acceptance.test_organization_events_v2 import generate_transaction

FEATURE_NAMES = ["organizations:performance-view"]
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/tests.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from unittest import mock

from django.conf import settings

from sentry.testutils import TestCase
from sentry.utils.compat import mock
from sentry.utils.settings import ConfigurationError, import_string, validate_settings

DEPENDENCY_TEST_DATA = {
Expand Down
2 changes: 1 addition & 1 deletion tests/relay_integration/lang/javascript/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import zipfile
from base64 import b64encode
from io import BytesIO
from unittest.mock import patch

import responses
from django.utils.encoding import force_bytes
Expand All @@ -11,7 +12,6 @@
from sentry.testutils import RelayStoreHelper, SnubaTestCase, TransactionTestCase
from sentry.testutils.helpers.datetime import before_now, iso_format
from sentry.utils import json
from sentry.utils.compat.mock import patch

BASE64_SOURCEMAP = "data:application/json;base64," + (
b64encode(
Expand Down
2 changes: 1 addition & 1 deletion tests/relay_integration/test_sdk.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import uuid
from unittest import mock

import pytest
import sentry_sdk
Expand All @@ -7,7 +8,6 @@

from sentry import eventstore
from sentry.testutils import assert_mock_called_once_with_partial
from sentry.utils.compat import mock
from sentry.utils.pytest.relay import adjust_settings_for_relay_tests
from sentry.utils.sdk import bind_organization_context, configure_sdk

Expand Down
2 changes: 1 addition & 1 deletion tests/sentry/analytics/test_event.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from datetime import datetime
from unittest.mock import patch

import pytest
import pytz

from sentry.analytics import Attribute, Event, Map
from sentry.testutils import TestCase
from sentry.utils.compat.mock import patch


class ExampleEvent(Event):
Expand Down
3 changes: 2 additions & 1 deletion tests/sentry/api/bases/test_endpoint.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from unittest.mock import Mock

from django.http import QueryDict

from sentry.api.base import Endpoint
from sentry.testutils import TestCase
from sentry.utils.compat.mock import Mock


class EndpointTest(TestCase):
Expand Down
2 changes: 1 addition & 1 deletion tests/sentry/api/bases/test_organization.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from datetime import timedelta
from unittest import mock

from django.db.models import F
from django.test import RequestFactory
Expand All @@ -14,7 +15,6 @@
from sentry.auth.authenticators import TotpInterface
from sentry.models import ApiKey, Organization, OrganizationMember
from sentry.testutils import TestCase
from sentry.utils.compat import mock


class MockSuperUser:
Expand Down
3 changes: 2 additions & 1 deletion tests/sentry/api/bases/test_sentryapps.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from unittest.mock import patch

from django.http import Http404

from sentry.api.bases.sentryapps import (
Expand All @@ -9,7 +11,6 @@
)
from sentry.testutils import TestCase
from sentry.testutils.helpers.faux import Mock
from sentry.utils.compat.mock import patch


class SentryAppPermissionTest(TestCase):
Expand Down
3 changes: 2 additions & 1 deletion tests/sentry/api/endpoints/test_auth_login.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from unittest.mock import patch

from django.urls import reverse

from sentry.testutils import APITestCase
from sentry.utils.compat.mock import patch


class AuthLoginEndpointTest(APITestCase):
Expand Down
2 changes: 1 addition & 1 deletion tests/sentry/api/endpoints/test_dif_assemble.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from hashlib import sha1
from unittest.mock import patch

from django.core.files.base import ContentFile
from django.urls import reverse
Expand All @@ -14,7 +15,6 @@
set_assemble_status,
)
from sentry.testutils import APITestCase
from sentry.utils.compat.mock import patch


class DifAssembleEndpoint(APITestCase):
Expand Down
Loading