فهرست منبع

Refs #23919 -- Removed django.test.mock Python 2 compatibility shim.

Tim Graham 8 سال پیش
والد
کامیت
7aba69145d
49فایلهای تغییر یافته به همراه97 افزوده شده و 81 حذف شده
  1. 0 9
      django/test/__init__.py
  2. 2 1
      tests/admin_scripts/tests.py
  3. 3 1
      tests/admin_views/test_multidb.py
  4. 3 1
      tests/auth_tests/test_admin_multidb.py
  5. 2 1
      tests/auth_tests/test_auth_backends.py
  6. 2 1
      tests/auth_tests/test_forms.py
  7. 2 2
      tests/auth_tests/test_hashers.py
  8. 2 1
      tests/auth_tests/test_management.py
  9. 3 1
      tests/auth_tests/test_mixins.py
  10. 3 1
      tests/auth_tests/test_models.py
  11. 2 2
      tests/backends/test_features.py
  12. 2 1
      tests/backends/tests.py
  13. 2 1
      tests/cache/tests.py
  14. 2 1
      tests/check_framework/test_database.py
  15. 3 1
      tests/check_framework/test_multi_db.py
  16. 2 1
      tests/contenttypes_tests/tests.py
  17. 2 1
      tests/dbshell/test_postgresql_psycopg2.py
  18. 1 1
      tests/files/tests.py
  19. 2 3
      tests/fixtures/tests.py
  20. 2 1
      tests/forms_tests/tests/test_formsets.py
  21. 1 1
      tests/gis_tests/gdal_tests/test_driver.py
  22. 2 2
      tests/gis_tests/geos_tests/test_geos.py
  23. 1 2
      tests/gis_tests/test_geoip2.py
  24. 2 1
      tests/gis_tests/test_ptr.py
  25. 2 1
      tests/i18n/test_compilation.py
  26. 2 2
      tests/i18n/test_extraction.py
  27. 2 2
      tests/inspectdb/tests.py
  28. 2 2
      tests/introspection/tests.py
  29. 3 1
      tests/invalid_models_tests/test_backend_specific.py
  30. 2 1
      tests/migrations/test_autodetector.py
  31. 2 1
      tests/migrations/test_commands.py
  32. 2 1
      tests/migrations/test_writer.py
  33. 2 1
      tests/postgres_tests/migrations/0001_setup_extensions.py
  34. 0 5
      tests/requirements/py2.txt
  35. 0 10
      tests/runtests.py
  36. 2 1
      tests/schema/tests.py
  37. 2 1
      tests/select_for_update/tests.py
  38. 2 3
      tests/serializers/tests.py
  39. 2 1
      tests/shell/tests.py
  40. 3 1
      tests/signals/tests.py
  41. 2 1
      tests/sitemaps_tests/test_management.py
  42. 2 1
      tests/sitemaps_tests/test_utils.py
  43. 2 1
      tests/staticfiles_tests/test_management.py
  44. 2 1
      tests/test_runner/tests.py
  45. 3 1
      tests/test_utils/test_transactiontestcase.py
  46. 2 1
      tests/urlpatterns_reverse/test_localeregexprovider.py
  47. 2 1
      tests/user_commands/tests.py
  48. 2 1
      tests/utils_tests/test_autoreload.py
  49. 2 1
      tests/utils_tests/test_timezone.py

+ 0 - 9
django/test/__init__.py

@@ -18,12 +18,3 @@ __all__ = [
     'skipUnlessAnyDBFeature', 'skipUnlessDBFeature', 'ignore_warnings',
     'modify_settings', 'override_settings', 'override_system_checks', 'tag',
 ]
-
-# To simplify Django's test suite; not meant as a public API
-try:
-    from unittest import mock  # NOQA
-except ImportError:
-    try:
-        import mock  # NOQA
-    except ImportError:
-        pass

+ 2 - 1
tests/admin_scripts/tests.py

@@ -13,6 +13,7 @@ import sys
 import tempfile
 import unittest
 from io import StringIO
+from unittest import mock
 
 import django
 from django import conf, get_version
@@ -24,7 +25,7 @@ from django.db import ConnectionHandler
 from django.db.migrations.exceptions import MigrationSchemaMissing
 from django.db.migrations.recorder import MigrationRecorder
 from django.test import (
-    LiveServerTestCase, SimpleTestCase, TestCase, mock, override_settings,
+    LiveServerTestCase, SimpleTestCase, TestCase, override_settings,
 )
 from django.utils.encoding import force_text
 

+ 3 - 1
tests/admin_views/test_multidb.py

@@ -1,8 +1,10 @@
+from unittest import mock
+
 from django.conf.urls import url
 from django.contrib import admin
 from django.contrib.auth.models import User
 from django.db import connections
-from django.test import TestCase, mock, override_settings
+from django.test import TestCase, override_settings
 from django.urls import reverse
 
 from .models import Book

+ 3 - 1
tests/auth_tests/test_admin_multidb.py

@@ -1,9 +1,11 @@
+from unittest import mock
+
 from django.conf.urls import url
 from django.contrib import admin
 from django.contrib.auth.admin import UserAdmin
 from django.contrib.auth.models import User
 from django.db import connections
-from django.test import TestCase, mock, override_settings
+from django.test import TestCase, override_settings
 from django.urls import reverse
 
 

+ 2 - 1
tests/auth_tests/test_auth_backends.py

@@ -1,4 +1,5 @@
 from datetime import date
+from unittest import mock
 
 from django.contrib.auth import (
     BACKEND_SESSION_KEY, SESSION_KEY, authenticate, get_user, signals,
@@ -10,7 +11,7 @@ from django.contrib.contenttypes.models import ContentType
 from django.core.exceptions import ImproperlyConfigured, PermissionDenied
 from django.http import HttpRequest
 from django.test import (
-    SimpleTestCase, TestCase, mock, modify_settings, override_settings,
+    SimpleTestCase, TestCase, modify_settings, override_settings,
 )
 
 from .models import (

+ 2 - 1
tests/auth_tests/test_forms.py

@@ -1,5 +1,6 @@
 import datetime
 import re
+from unittest import mock
 
 from django import forms
 from django.contrib.auth.forms import (
@@ -13,7 +14,7 @@ from django.contrib.sites.models import Site
 from django.core import mail
 from django.core.mail import EmailMultiAlternatives
 from django.forms.fields import CharField, Field, IntegerField
-from django.test import SimpleTestCase, TestCase, mock, override_settings
+from django.test import SimpleTestCase, TestCase, override_settings
 from django.utils import translation
 from django.utils.encoding import force_text
 from django.utils.text import capfirst

+ 2 - 2
tests/auth_tests/test_hashers.py

@@ -1,4 +1,4 @@
-from unittest import skipUnless
+from unittest import mock, skipUnless
 
 from django.conf.global_settings import PASSWORD_HASHERS
 from django.contrib.auth.hashers import (
@@ -7,7 +7,7 @@ from django.contrib.auth.hashers import (
     check_password, get_hasher, identify_hasher, is_password_usable,
     make_password,
 )
-from django.test import SimpleTestCase, mock
+from django.test import SimpleTestCase
 from django.test.utils import override_settings
 from django.utils.encoding import force_bytes
 

+ 2 - 1
tests/auth_tests/test_management.py

@@ -2,6 +2,7 @@ import builtins
 import sys
 from datetime import date
 from io import StringIO
+from unittest import mock
 
 from django.apps import apps
 from django.contrib.auth import management
@@ -14,7 +15,7 @@ from django.contrib.contenttypes.models import ContentType
 from django.core.management import call_command
 from django.core.management.base import CommandError
 from django.db import migrations
-from django.test import TestCase, mock, override_settings
+from django.test import TestCase, override_settings
 from django.utils.translation import ugettext_lazy as _
 
 from .models import (

+ 3 - 1
tests/auth_tests/test_mixins.py

@@ -1,3 +1,5 @@
+from unittest import mock
+
 from django.contrib.auth import models
 from django.contrib.auth.mixins import (
     LoginRequiredMixin, PermissionRequiredMixin, UserPassesTestMixin,
@@ -5,7 +7,7 @@ from django.contrib.auth.mixins import (
 from django.contrib.auth.models import AnonymousUser
 from django.core.exceptions import PermissionDenied
 from django.http import HttpResponse
-from django.test import RequestFactory, TestCase, mock
+from django.test import RequestFactory, TestCase
 from django.views.generic import View
 
 

+ 3 - 1
tests/auth_tests/test_models.py

@@ -1,3 +1,5 @@
+from unittest import mock
+
 from django.conf.global_settings import PASSWORD_HASHERS
 from django.contrib.auth import get_user_model
 from django.contrib.auth.base_user import AbstractBaseUser
@@ -8,7 +10,7 @@ from django.contrib.auth.models import (
 from django.contrib.contenttypes.models import ContentType
 from django.core import mail
 from django.db.models.signals import post_save
-from django.test import TestCase, mock, override_settings
+from django.test import TestCase, override_settings
 
 from .models.with_custom_email_field import CustomEmailField
 

+ 2 - 2
tests/backends/test_features.py

@@ -1,7 +1,7 @@
-from unittest import skipUnless
+from unittest import mock, skipUnless
 
 from django.db import connection
-from django.test import TestCase, mock
+from django.test import TestCase
 
 
 class TestDatabaseFeatures(TestCase):

+ 2 - 1
tests/backends/tests.py

@@ -5,6 +5,7 @@ import threading
 import unittest
 import warnings
 from decimal import Decimal, Rounded
+from unittest import mock
 
 from django.core.exceptions import ImproperlyConfigured
 from django.core.management.color import no_style
@@ -20,7 +21,7 @@ from django.db.models import Avg, StdDev, Sum, Variance
 from django.db.models.sql.constants import CURSOR
 from django.db.utils import ConnectionHandler
 from django.test import (
-    SimpleTestCase, TestCase, TransactionTestCase, mock, override_settings,
+    SimpleTestCase, TestCase, TransactionTestCase, override_settings,
     skipIfDBFeature, skipUnlessDBFeature,
 )
 

+ 2 - 1
tests/cache/tests.py

@@ -11,6 +11,7 @@ import threading
 import time
 import unittest
 import warnings
+from unittest import mock
 
 from django.conf import settings
 from django.core import management, signals
@@ -31,7 +32,7 @@ from django.template.context_processors import csrf
 from django.template.response import TemplateResponse
 from django.test import (
     RequestFactory, SimpleTestCase, TestCase, TransactionTestCase,
-    ignore_warnings, mock, override_settings,
+    ignore_warnings, override_settings,
 )
 from django.test.signals import setting_changed
 from django.utils import timezone, translation

+ 2 - 1
tests/check_framework/test_database.py

@@ -1,9 +1,10 @@
 import unittest
+from unittest import mock
 
 from django.core.checks import Tags, run_checks
 from django.core.checks.registry import CheckRegistry
 from django.db import connection
-from django.test import TestCase, mock
+from django.test import TestCase
 
 
 class DatabaseCheckTests(TestCase):

+ 3 - 1
tests/check_framework/test_multi_db.py

@@ -1,5 +1,7 @@
+from unittest import mock
+
 from django.db import connections, models
-from django.test import TestCase, mock
+from django.test import TestCase
 from django.test.utils import isolate_apps, override_settings
 
 

+ 2 - 1
tests/contenttypes_tests/tests.py

@@ -1,4 +1,5 @@
 import datetime
+from unittest import mock
 
 from django.apps.registry import Apps, apps
 from django.conf import settings
@@ -12,7 +13,7 @@ from django.core import checks, management
 from django.core.management import call_command
 from django.db import connections, migrations, models
 from django.test import (
-    SimpleTestCase, TestCase, TransactionTestCase, mock, override_settings,
+    SimpleTestCase, TestCase, TransactionTestCase, override_settings,
 )
 from django.test.utils import captured_stdout, isolate_apps
 from django.utils.encoding import force_text

+ 2 - 1
tests/dbshell/test_postgresql_psycopg2.py

@@ -1,7 +1,8 @@
 import os
+from unittest import mock
 
 from django.db.backends.postgresql.client import DatabaseClient
-from django.test import SimpleTestCase, mock
+from django.test import SimpleTestCase
 
 
 class PostgreSqlDbshellCommandTestCase(SimpleTestCase):

+ 1 - 1
tests/files/tests.py

@@ -4,13 +4,13 @@ import struct
 import tempfile
 import unittest
 from io import BytesIO, StringIO, TextIOWrapper
+from unittest import mock
 
 from django.core.files import File
 from django.core.files.base import ContentFile
 from django.core.files.move import file_move_safe
 from django.core.files.temp import NamedTemporaryFile
 from django.core.files.uploadedfile import SimpleUploadedFile, UploadedFile
-from django.test import mock
 
 try:
     from PIL import Image

+ 2 - 3
tests/fixtures/tests.py

@@ -4,6 +4,7 @@ import tempfile
 import unittest
 import warnings
 from io import StringIO
+from unittest import mock
 
 from django.apps import apps
 from django.contrib.sites.models import Site
@@ -13,9 +14,7 @@ from django.core.management import CommandError
 from django.core.management.commands.dumpdata import ProxyModelWarning
 from django.core.serializers.base import ProgressBar
 from django.db import IntegrityError, connection
-from django.test import (
-    TestCase, TransactionTestCase, mock, skipUnlessDBFeature,
-)
+from django.test import TestCase, TransactionTestCase, skipUnlessDBFeature
 from django.utils.encoding import force_text
 
 from .models import (

+ 2 - 1
tests/forms_tests/tests/test_formsets.py

@@ -1,5 +1,6 @@
 import datetime
 from collections import Counter
+from unittest import mock
 
 from django.forms import (
     BaseForm, CharField, DateField, FileField, Form, IntegerField,
@@ -7,7 +8,7 @@ from django.forms import (
 )
 from django.forms.formsets import BaseFormSet, formset_factory
 from django.forms.utils import ErrorList
-from django.test import SimpleTestCase, mock
+from django.test import SimpleTestCase
 from django.utils.encoding import force_text
 
 

+ 1 - 1
tests/gis_tests/gdal_tests/test_driver.py

@@ -1,7 +1,7 @@
 import unittest
+from unittest import mock
 
 from django.contrib.gis.gdal import HAS_GDAL
-from django.test import mock
 
 if HAS_GDAL:
     from django.contrib.gis.gdal import Driver, GDALException

+ 2 - 2
tests/gis_tests/geos_tests/test_geos.py

@@ -4,7 +4,7 @@ import pickle
 import random
 from binascii import a2b_hex, b2a_hex
 from io import BytesIO
-from unittest import skipUnless
+from unittest import mock, skipUnless
 
 from django.contrib.gis import gdal
 from django.contrib.gis.gdal import HAS_GDAL
@@ -17,7 +17,7 @@ from django.contrib.gis.geos.libgeos import geos_version_info
 from django.contrib.gis.shortcuts import numpy
 from django.template import Context
 from django.template.engine import Engine
-from django.test import SimpleTestCase, mock
+from django.test import SimpleTestCase
 from django.utils.encoding import force_bytes
 
 from ..test_data import TestDataMixin

+ 1 - 2
tests/gis_tests/test_geoip2.py

@@ -1,11 +1,10 @@
 import os
 import unittest
-from unittest import skipUnless
+from unittest import mock, skipUnless
 
 from django.conf import settings
 from django.contrib.gis.geoip2 import HAS_GEOIP2
 from django.contrib.gis.geos import HAS_GEOS, GEOSGeometry
-from django.test import mock
 
 if HAS_GEOIP2:
     from django.contrib.gis.geoip2 import GeoIP2, GeoIP2Exception

+ 2 - 1
tests/gis_tests/test_ptr.py

@@ -1,7 +1,8 @@
 import ctypes
+from unittest import mock
 
 from django.contrib.gis.ptr import CPointerBase
-from django.test import SimpleTestCase, mock
+from django.test import SimpleTestCase
 
 
 class CPointerBaseTests(SimpleTestCase):

+ 2 - 1
tests/i18n/test_compilation.py

@@ -4,6 +4,7 @@ import stat
 import unittest
 from io import StringIO
 from subprocess import Popen
+from unittest import mock
 
 from django.core.management import (
     CommandError, call_command, execute_from_command_line,
@@ -11,7 +12,7 @@ from django.core.management import (
 from django.core.management.commands.makemessages import \
     Command as MakeMessagesCommand
 from django.core.management.utils import find_command
-from django.test import SimpleTestCase, mock, override_settings
+from django.test import SimpleTestCase, override_settings
 from django.test.utils import captured_stderr, captured_stdout
 from django.utils import translation
 from django.utils.encoding import force_text

+ 2 - 2
tests/i18n/test_extraction.py

@@ -4,7 +4,7 @@ import shutil
 import time
 import warnings
 from io import StringIO
-from unittest import skipUnless
+from unittest import mock, skipUnless
 
 from admin_scripts.tests import AdminScriptTestCase
 
@@ -14,7 +14,7 @@ from django.core.management.base import CommandError
 from django.core.management.commands.makemessages import \
     Command as MakeMessagesCommand
 from django.core.management.utils import find_command
-from django.test import SimpleTestCase, mock, override_settings
+from django.test import SimpleTestCase, override_settings
 from django.test.utils import captured_stderr, captured_stdout
 from django.utils.encoding import force_text
 from django.utils.translation import TranslatorCommentWarning

+ 2 - 2
tests/inspectdb/tests.py

@@ -1,10 +1,10 @@
 import re
 from io import StringIO
-from unittest import skipUnless
+from unittest import mock, skipUnless
 
 from django.core.management import call_command
 from django.db import connection
-from django.test import TestCase, mock, skipUnlessDBFeature
+from django.test import TestCase, skipUnlessDBFeature
 from django.utils.encoding import force_text
 
 from .models import ColumnTypes

+ 2 - 2
tests/introspection/tests.py

@@ -1,8 +1,8 @@
-from unittest import skipUnless
+from unittest import mock, skipUnless
 
 from django.db import connection
 from django.db.utils import DatabaseError
-from django.test import TransactionTestCase, mock, skipUnlessDBFeature
+from django.test import TransactionTestCase, skipUnlessDBFeature
 from django.test.utils import ignore_warnings
 from django.utils.deprecation import RemovedInDjango21Warning
 

+ 3 - 1
tests/invalid_models_tests/test_backend_specific.py

@@ -1,6 +1,8 @@
+from unittest import mock
+
 from django.core.checks import Error
 from django.db import connections, models
-from django.test import SimpleTestCase, mock
+from django.test import SimpleTestCase
 from django.test.utils import isolate_apps
 
 

+ 2 - 1
tests/migrations/test_autodetector.py

@@ -1,5 +1,6 @@
 import functools
 import re
+from unittest import mock
 
 from django.apps import apps
 from django.conf import settings
@@ -11,7 +12,7 @@ from django.db.migrations.graph import MigrationGraph
 from django.db.migrations.loader import MigrationLoader
 from django.db.migrations.questioner import MigrationQuestioner
 from django.db.migrations.state import ModelState, ProjectState
-from django.test import TestCase, mock, override_settings
+from django.test import TestCase, override_settings
 from django.test.utils import isolate_lru_cache
 
 from .models import FoodManager, FoodQuerySet

+ 2 - 1
tests/migrations/test_commands.py

@@ -3,6 +3,7 @@ import importlib
 import io
 import os
 import sys
+from unittest import mock
 
 from django.apps import apps
 from django.core.management import CommandError, call_command
@@ -14,7 +15,7 @@ from django.db.migrations.exceptions import (
     InconsistentMigrationHistory, MigrationSchemaMissing,
 )
 from django.db.migrations.recorder import MigrationRecorder
-from django.test import mock, override_settings
+from django.test import override_settings
 from django.utils.encoding import force_text
 
 from .models import UnicodeModel, UnserializableModel

+ 2 - 1
tests/migrations/test_writer.py

@@ -7,6 +7,7 @@ import os
 import re
 import sys
 import uuid
+from unittest import mock
 
 import custom_migration_operations.more_operations
 import custom_migration_operations.operations
@@ -18,7 +19,7 @@ from django.db import migrations, models
 from django.db.migrations.writer import (
     MigrationWriter, OperationWriter, SettingsReference,
 )
-from django.test import SimpleTestCase, mock
+from django.test import SimpleTestCase
 from django.utils import datetime_safe
 from django.utils.deconstruct import deconstructible
 from django.utils.functional import SimpleLazyObject

+ 2 - 1
tests/postgres_tests/migrations/0001_setup_extensions.py

@@ -1,3 +1,5 @@
+from unittest import mock
+
 from django.db import migrations
 
 try:
@@ -6,7 +8,6 @@ try:
         TrigramExtension, UnaccentExtension,
     )
 except ImportError:
-    from django.test import mock
     BtreeGinExtension = mock.Mock()
     CreateExtension = mock.Mock()
     HStoreExtension = mock.Mock()

+ 0 - 5
tests/requirements/py2.txt

@@ -1,5 +0,0 @@
--r base.txt
-enum34
-# Due to https://github.com/linsomniac/python-memcached/issues/79 in newer versions.
-python-memcached <= 1.53
-mock

+ 0 - 10
tests/runtests.py

@@ -437,16 +437,6 @@ if __name__ == "__main__":
 
     options = parser.parse_args()
 
-    # mock is a required dependency
-    try:
-        from django.test import mock  # NOQA
-    except ImportError:
-        print(
-            "Please install test dependencies first: \n"
-            "$ pip install -r requirements/py%s.txt" % sys.version_info.major
-        )
-        sys.exit(1)
-
     # Allow including a trailing slash on app_labels for tab completion convenience
     options.modules = [os.path.normpath(labels) for labels in options.modules]
 

+ 2 - 1
tests/schema/tests.py

@@ -2,6 +2,7 @@ import datetime
 import itertools
 import unittest
 from copy import copy
+from unittest import mock
 
 from django.db import (
     DatabaseError, IntegrityError, OperationalError, connection,
@@ -19,7 +20,7 @@ from django.db.models.fields.related import (
 from django.db.models.indexes import Index
 from django.db.transaction import TransactionManagementError, atomic
 from django.test import (
-    TransactionTestCase, mock, skipIfDBFeature, skipUnlessDBFeature,
+    TransactionTestCase, skipIfDBFeature, skipUnlessDBFeature,
 )
 from django.test.utils import CaptureQueriesContext
 from django.utils import timezone

+ 2 - 1
tests/select_for_update/tests.py

@@ -1,5 +1,6 @@
 import threading
 import time
+from unittest import mock
 
 from multiple_database.routers import TestRouter
 
@@ -7,7 +8,7 @@ from django.db import (
     DatabaseError, connection, connections, router, transaction,
 )
 from django.test import (
-    TransactionTestCase, mock, override_settings, skipIfDBFeature,
+    TransactionTestCase, override_settings, skipIfDBFeature,
     skipUnlessDBFeature,
 )
 from django.test.utils import CaptureQueriesContext

+ 2 - 3
tests/serializers/tests.py

@@ -1,14 +1,13 @@
 from datetime import datetime
 from io import StringIO
+from unittest import mock
 
 from django.core import serializers
 from django.core.serializers import SerializerDoesNotExist
 from django.core.serializers.base import ProgressBar
 from django.db import connection, transaction
 from django.http import HttpResponse
-from django.test import (
-    SimpleTestCase, mock, override_settings, skipUnlessDBFeature,
-)
+from django.test import SimpleTestCase, override_settings, skipUnlessDBFeature
 from django.test.utils import Approximate
 from django.utils.functional import curry
 

+ 2 - 1
tests/shell/tests.py

@@ -1,9 +1,10 @@
 import sys
 import unittest
+from unittest import mock
 
 from django import __version__
 from django.core.management import CommandError, call_command
-from django.test import SimpleTestCase, mock
+from django.test import SimpleTestCase
 from django.test.utils import captured_stdin, captured_stdout, patch_logger
 
 

+ 3 - 1
tests/signals/tests.py

@@ -1,8 +1,10 @@
+from unittest import mock
+
 from django.apps.registry import Apps
 from django.db import models
 from django.db.models import signals
 from django.dispatch import receiver
-from django.test import TestCase, mock
+from django.test import TestCase
 from django.test.utils import isolate_apps
 
 from .models import Author, Book, Car, Person

+ 2 - 1
tests/sitemaps_tests/test_management.py

@@ -1,5 +1,6 @@
+from unittest import mock
+
 from django.core.management import call_command
-from django.test import mock
 
 from .base import SitemapTestsBase
 

+ 2 - 1
tests/sitemaps_tests/test_utils.py

@@ -1,10 +1,11 @@
+from unittest import mock
 from urllib.parse import urlencode
 
 from django.contrib.sitemaps import (
     SitemapNotFound, _get_sitemap_full_url, ping_google,
 )
 from django.core.exceptions import ImproperlyConfigured
-from django.test import mock, modify_settings, override_settings
+from django.test import modify_settings, override_settings
 
 from .base import SitemapTestsBase
 

+ 2 - 1
tests/staticfiles_tests/test_management.py

@@ -5,6 +5,7 @@ import shutil
 import tempfile
 import unittest
 from io import StringIO
+from unittest import mock
 
 from admin_scripts.tests import AdminScriptTestCase
 
@@ -13,7 +14,7 @@ from django.contrib.staticfiles import storage
 from django.contrib.staticfiles.management.commands import collectstatic
 from django.core.exceptions import ImproperlyConfigured
 from django.core.management import call_command
-from django.test import mock, override_settings
+from django.test import override_settings
 from django.test.utils import extend_sys_path
 from django.utils import timezone
 from django.utils._os import symlinks_supported

+ 2 - 1
tests/test_runner/tests.py

@@ -2,6 +2,7 @@
 Tests for django test runner
 """
 import unittest
+from unittest import mock
 
 from admin_scripts.tests import AdminScriptTestCase
 
@@ -10,7 +11,7 @@ from django.conf import settings
 from django.core.exceptions import ImproperlyConfigured
 from django.core.management import call_command
 from django.test import (
-    TestCase, TransactionTestCase, mock, skipUnlessDBFeature, testcases,
+    TestCase, TransactionTestCase, skipUnlessDBFeature, testcases,
 )
 from django.test.runner import DiscoverRunner
 from django.test.testcases import connections_support_transactions

+ 3 - 1
tests/test_utils/test_transactiontestcase.py

@@ -1,4 +1,6 @@
-from django.test import TransactionTestCase, mock
+from unittest import mock
+
+from django.test import TransactionTestCase
 
 
 class TestSerializedRollbackInhibitsPostMigrate(TransactionTestCase):

+ 2 - 1
tests/urlpatterns_reverse/test_localeregexprovider.py

@@ -1,7 +1,8 @@
 import os
+from unittest import mock
 
 from django.core.exceptions import ImproperlyConfigured
-from django.test import SimpleTestCase, mock, override_settings
+from django.test import SimpleTestCase, override_settings
 from django.urls import LocaleRegexProvider
 from django.urls.resolvers import LocaleRegexDescriptor
 from django.utils import translation

+ 2 - 1
tests/user_commands/tests.py

@@ -1,5 +1,6 @@
 import os
 from io import StringIO
+from unittest import mock
 
 from admin_scripts.tests import AdminScriptTestCase
 
@@ -8,7 +9,7 @@ from django.core import management
 from django.core.management import BaseCommand, CommandError, find_commands
 from django.core.management.utils import find_command, popen_wrapper
 from django.db import connection
-from django.test import SimpleTestCase, mock, override_settings
+from django.test import SimpleTestCase, override_settings
 from django.test.utils import captured_stderr, extend_sys_path
 from django.utils import translation
 

+ 2 - 1
tests/utils_tests/test_autoreload.py

@@ -3,12 +3,13 @@ import os
 import shutil
 import tempfile
 from importlib import import_module
+from unittest import mock
 
 import _thread
 
 from django import conf
 from django.contrib import admin
-from django.test import SimpleTestCase, mock, override_settings
+from django.test import SimpleTestCase, override_settings
 from django.test.utils import extend_sys_path
 from django.utils import autoreload
 from django.utils.translation import trans_real

+ 2 - 1
tests/utils_tests/test_timezone.py

@@ -1,9 +1,10 @@
 import datetime
 import pickle
+from unittest import mock
 
 import pytz
 
-from django.test import SimpleTestCase, mock, override_settings
+from django.test import SimpleTestCase, override_settings
 from django.utils import timezone
 
 CET = pytz.timezone("Europe/Paris")