launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #27396
[Merge] ~cjwatson/launchpad:py3only-unittest-mock into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:py3only-unittest-mock into launchpad:master.
Commit message:
Use unittest.mock directly
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/406943
We no longer need the compatibility layer now that we require Python >= 3.5.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3only-unittest-mock into launchpad:master.
diff --git a/lib/lp/app/stories/basics/xx-opstats.txt b/lib/lp/app/stories/basics/xx-opstats.txt
index 558131b..f2e37e1 100644
--- a/lib/lp/app/stories/basics/xx-opstats.txt
+++ b/lib/lp/app/stories/basics/xx-opstats.txt
@@ -14,9 +14,9 @@ We can access them via XML-RPC:
We also emit similar metrics to statsd, so set that up.
>>> from textwrap import dedent
+ >>> from unittest import mock
>>> from fixtures import MockPatchObject
>>> from zope.component import getUtility
- >>> from lp.services.compat import mock
>>> from lp.services.config import config
>>> from lp.services.statsd.interfaces.statsd_client import IStatsdClient
diff --git a/lib/lp/archivepublisher/tests/test_archivegpgsigningkey.py b/lib/lp/archivepublisher/tests/test_archivegpgsigningkey.py
index f32c124..6632931 100644
--- a/lib/lp/archivepublisher/tests/test_archivegpgsigningkey.py
+++ b/lib/lp/archivepublisher/tests/test_archivegpgsigningkey.py
@@ -7,6 +7,7 @@ __metaclass__ = type
import os
from textwrap import dedent
+from unittest import mock
import six
from testtools.matchers import (
@@ -37,7 +38,6 @@ from lp.archivepublisher.interfaces.archivegpgsigningkey import (
from lp.archivepublisher.interfaces.publisherconfig import IPublisherConfigSet
from lp.archivepublisher.tests.test_run_parts import RunPartsMixin
from lp.registry.interfaces.gpg import IGPGKeySet
-from lp.services.compat import mock
from lp.services.features.testing import FeatureFixture
from lp.services.gpg.interfaces import IGPGHandler
from lp.services.gpg.tests.test_gpghandler import FakeGenerateKey
diff --git a/lib/lp/archivepublisher/tests/test_publisher.py b/lib/lp/archivepublisher/tests/test_publisher.py
index 53f2d76..f2c62cf 100644
--- a/lib/lp/archivepublisher/tests/test_publisher.py
+++ b/lib/lp/archivepublisher/tests/test_publisher.py
@@ -27,6 +27,7 @@ import stat
import tempfile
from textwrap import dedent
import time
+from unittest import mock
from debian.deb822 import Release
from fixtures import MonkeyPatch
@@ -83,7 +84,6 @@ from lp.registry.interfaces.pocket import (
pocketsuffix,
)
from lp.registry.interfaces.series import SeriesStatus
-from lp.services.compat import mock
from lp.services.config import config
from lp.services.database.constants import UTC_NOW
from lp.services.database.sqlbase import flush_database_caches
diff --git a/lib/lp/archivepublisher/tests/test_sync_signingkeys.py b/lib/lp/archivepublisher/tests/test_sync_signingkeys.py
index 24dd57f..cc01135 100644
--- a/lib/lp/archivepublisher/tests/test_sync_signingkeys.py
+++ b/lib/lp/archivepublisher/tests/test_sync_signingkeys.py
@@ -15,6 +15,7 @@ __all__ = [
from datetime import datetime
import os
from textwrap import dedent
+from unittest import mock
from fixtures import (
MockPatch,
@@ -41,7 +42,6 @@ from lp.archivepublisher.interfaces.archivegpgsigningkey import (
)
from lp.archivepublisher.model.publisherconfig import PublisherConfig
from lp.archivepublisher.scripts.sync_signingkeys import SyncSigningKeysScript
-from lp.services.compat import mock
from lp.services.config import config
from lp.services.config.fixture import (
ConfigFixture,
diff --git a/lib/lp/archiveuploader/tests/test_nascentuploadfile.py b/lib/lp/archiveuploader/tests/test_nascentuploadfile.py
index cedc89a..ce267a4 100644
--- a/lib/lp/archiveuploader/tests/test_nascentuploadfile.py
+++ b/lib/lp/archiveuploader/tests/test_nascentuploadfile.py
@@ -13,6 +13,7 @@ import lzma
import os
import subprocess
import tarfile
+from unittest import mock
from debian.deb822 import (
Changes,
@@ -41,7 +42,6 @@ from lp.archiveuploader.nascentuploadfile import (
from lp.archiveuploader.tests import AbsolutelyAnythingGoesUploadPolicy
from lp.buildmaster.enums import BuildStatus
from lp.registry.interfaces.pocket import PackagePublishingPocket
-from lp.services.compat import mock
from lp.services.log.logger import BufferLogger
from lp.services.osutils import write_file
from lp.soyuz.enums import (
diff --git a/lib/lp/buildmaster/tests/test_manager.py b/lib/lp/buildmaster/tests/test_manager.py
index 9f49176..ada37a0 100644
--- a/lib/lp/buildmaster/tests/test_manager.py
+++ b/lib/lp/buildmaster/tests/test_manager.py
@@ -10,6 +10,7 @@
import os
import signal
import time
+from unittest import mock
import six
from six.moves import xmlrpc_client
@@ -70,7 +71,6 @@ from lp.buildmaster.tests.test_interactor import (
MockBuilderFactory,
)
from lp.registry.interfaces.distribution import IDistributionSet
-from lp.services.compat import mock
from lp.services.config import config
from lp.services.log.logger import BufferLogger
from lp.services.statsd.tests import StatsMixin
diff --git a/lib/lp/code/model/tests/test_gitnamespace.py b/lib/lp/code/model/tests/test_gitnamespace.py
index 3b7bfcd..3c4ac13 100644
--- a/lib/lp/code/model/tests/test_gitnamespace.py
+++ b/lib/lp/code/model/tests/test_gitnamespace.py
@@ -3,6 +3,8 @@
"""Tests for `IGitNamespace` implementations."""
+from unittest import mock
+
import six
from zope.component import getUtility
from zope.security.proxy import removeSecurityProxy
@@ -45,7 +47,6 @@ from lp.registry.interfaces.accesspolicy import (
IAccessPolicyGrantFlatSource,
IAccessPolicySource,
)
-from lp.services.compat import mock
from lp.testing import (
person_logged_in,
TestCaseWithFactory,
diff --git a/lib/lp/oci/tests/test_ocirecipebuildjob.py b/lib/lp/oci/tests/test_ocirecipebuildjob.py
index d2b3929..591e5e4 100644
--- a/lib/lp/oci/tests/test_ocirecipebuildjob.py
+++ b/lib/lp/oci/tests/test_ocirecipebuildjob.py
@@ -7,6 +7,7 @@ __metaclass__ = type
import os
import signal
+from unittest import mock
from fixtures import FakeLogger
from storm.locals import Store
@@ -42,7 +43,6 @@ from lp.oci.model.ocirecipebuildjob import (
OCIRecipeBuildJobType,
OCIRegistryUploadJob,
)
-from lp.services.compat import mock
from lp.services.config import config
from lp.services.database.locking import (
LockType,
diff --git a/lib/lp/oci/tests/test_ociregistryclient.py b/lib/lp/oci/tests/test_ociregistryclient.py
index 0634ac0..6a10eed 100644
--- a/lib/lp/oci/tests/test_ociregistryclient.py
+++ b/lib/lp/oci/tests/test_ociregistryclient.py
@@ -14,6 +14,7 @@ import json
import os
import re
import tarfile
+from unittest import mock
import uuid
from fixtures import MockPatch
@@ -64,7 +65,6 @@ from lp.oci.model.ociregistryclient import (
)
from lp.oci.tests.helpers import OCIConfigHelperMixin
from lp.registry.interfaces.series import SeriesStatus
-from lp.services.compat import mock
from lp.services.features.testing import FeatureFixture
from lp.services.tarfile_helpers import LaunchpadWriteTarFile
from lp.testing import (
diff --git a/lib/lp/scripts/utilities/test.py b/lib/lp/scripts/utilities/test.py
index 00795c2..35dbbe2 100755
--- a/lib/lp/scripts/utilities/test.py
+++ b/lib/lp/scripts/utilities/test.py
@@ -21,6 +21,7 @@ import re
import signal
import sys
import time
+from unittest import mock
import warnings
import distro
@@ -33,7 +34,6 @@ from lp.scripts.utilities import (
importpedant,
warninghandler,
)
-from lp.services.compat import mock
from lp.services.config import config
diff --git a/lib/lp/services/compat.py b/lib/lp/services/compat.py
index 3673a45..88df437 100644
--- a/lib/lp/services/compat.py
+++ b/lib/lp/services/compat.py
@@ -11,7 +11,6 @@ __all__ = [
'escape',
'message_as_bytes',
'message_from_bytes',
- 'mock',
]
try:
@@ -27,12 +26,6 @@ except ImportError:
import io
-try:
- import mock
-except ImportError:
- from unittest import mock
-
-
def message_as_bytes(message):
from email.generator import BytesGenerator
from email.policy import compat32
diff --git a/lib/lp/services/gpg/tests/test_gpghandler.py b/lib/lp/services/gpg/tests/test_gpghandler.py
index e929187..fe0f5d8 100644
--- a/lib/lp/services/gpg/tests/test_gpghandler.py
+++ b/lib/lp/services/gpg/tests/test_gpghandler.py
@@ -5,6 +5,7 @@ from datetime import datetime
import os
import shutil
import subprocess
+from unittest import mock
from fixtures import (
Fixture,
@@ -23,7 +24,6 @@ from testtools.matchers import (
from zope.component import getUtility
from zope.security.proxy import removeSecurityProxy
-from lp.services.compat import mock
from lp.services.features.testing import FeatureFixture
from lp.services.gpg.handler import signing_only_param
from lp.services.gpg.interfaces import (
diff --git a/lib/lp/services/job/tests/test_celery.py b/lib/lp/services/job/tests/test_celery.py
index d1000e3..fa50a01 100644
--- a/lib/lp/services/job/tests/test_celery.py
+++ b/lib/lp/services/job/tests/test_celery.py
@@ -9,6 +9,7 @@ from datetime import (
timedelta,
)
from time import sleep
+from unittest import mock
import iso8601
from lazr.delegates import delegate_to
@@ -24,7 +25,6 @@ from testtools.matchers import (
import transaction
from zope.interface import implementer
-from lp.services.compat import mock
from lp.services.config import config
from lp.services.database.interfaces import IStore
from lp.services.features.testing import FeatureFixture
diff --git a/lib/lp/services/scripts/doc/script-monitoring.txt b/lib/lp/services/scripts/doc/script-monitoring.txt
index 89a6406..f2765ab 100644
--- a/lib/lp/services/scripts/doc/script-monitoring.txt
+++ b/lib/lp/services/scripts/doc/script-monitoring.txt
@@ -23,13 +23,13 @@ IScriptActivitySet.recordSuccess():
>>> import subprocess
>>> import tempfile
>>> from textwrap import dedent
+ >>> from unittest import mock
>>> from fixtures import MockPatchObject
>>> import pytz
>>> import transaction
>>> from zope.component import getUtility
- >>> from lp.services.compat import mock
>>> from lp.services.config import config
>>> from lp.services.scripts.interfaces.scriptactivity import (
... IScriptActivitySet)
diff --git a/lib/lp/services/signing/tests/helpers.py b/lib/lp/services/signing/tests/helpers.py
index ee53228..6ea6121 100644
--- a/lib/lp/services/signing/tests/helpers.py
+++ b/lib/lp/services/signing/tests/helpers.py
@@ -8,10 +8,11 @@ __all__ = [
'SigningServiceClientFixture',
]
+from unittest import mock
+
import fixtures
from nacl.public import PrivateKey
-from lp.services.compat import mock
from lp.services.signing.interfaces.signingserviceclient import (
ISigningServiceClient,
)
diff --git a/lib/lp/services/statsd/tests/__init__.py b/lib/lp/services/statsd/tests/__init__.py
index 7ab45cc..52967e2 100644
--- a/lib/lp/services/statsd/tests/__init__.py
+++ b/lib/lp/services/statsd/tests/__init__.py
@@ -6,10 +6,11 @@
__metaclass__ = type
__all__ = ['StatsMixin']
+from unittest import mock
+
from fixtures import MockPatchObject
from zope.component import getUtility
-from lp.services.compat import mock
from lp.services.statsd.interfaces.statsd_client import IStatsdClient
diff --git a/lib/lp/services/tests/test_memoizer.py b/lib/lp/services/tests/test_memoizer.py
index 42197f3..9bea86a 100644
--- a/lib/lp/services/tests/test_memoizer.py
+++ b/lib/lp/services/tests/test_memoizer.py
@@ -3,7 +3,8 @@
"""Tests memoizer decorators"""
-from lp.services.compat import mock
+from unittest import mock
+
from lp.services.memoizer import memoize
from lp.testing import TestCase
diff --git a/lib/lp/services/webhooks/tests/test_job.py b/lib/lp/services/webhooks/tests/test_job.py
index 429f392..7700a46 100644
--- a/lib/lp/services/webhooks/tests/test_job.py
+++ b/lib/lp/services/webhooks/tests/test_job.py
@@ -10,6 +10,7 @@ from datetime import (
timedelta,
)
import re
+from unittest import mock
from fixtures import (
FakeLogger,
@@ -44,7 +45,6 @@ from lp.oci.interfaces.ocirecipe import (
OCI_RECIPE_ALLOW_CREATE,
OCI_RECIPE_WEBHOOKS_FEATURE_FLAG,
)
-from lp.services.compat import mock
from lp.services.database.interfaces import IStore
from lp.services.features.testing import FeatureFixture
from lp.services.job.interfaces.job import JobStatus
diff --git a/lib/lp/translations/doc/poexport-queue.txt b/lib/lp/translations/doc/poexport-queue.txt
index 562eb08..fb0bcb6 100644
--- a/lib/lp/translations/doc/poexport-queue.txt
+++ b/lib/lp/translations/doc/poexport-queue.txt
@@ -139,7 +139,7 @@ It's not clear that it's possible to trigger this failure mode normally on
Python 3 at all, because bytes will just be formatted as b'...'. For now,
inject a mock exception in that case so that the test can pass.
- >>> from lp.services.compat import mock
+ >>> from unittest import mock
>>> patcher = mock.patch.object(result, 'failure')
>>> mock_failure = patcher.start()
>>> mock_failure.__str__.side_effect = lambda: b'\xc3'.decode('UTF-8')
diff --git a/requirements/launchpad.txt b/requirements/launchpad.txt
index e770039..384c3bc 100644
--- a/requirements/launchpad.txt
+++ b/requirements/launchpad.txt
@@ -81,7 +81,6 @@ martian==1.3.post1
maxminddb==1.5.1
meliae==0.5.1
mistune==0.8.3
-mock==1.0.1
monotonic==1.5
multipart==0.1.1+lp1; python_version < "3"
multipart==0.2.4; python_version >= "3"
diff --git a/setup.py b/setup.py
index 5c4f42d..e47a0dc 100644
--- a/setup.py
+++ b/setup.py
@@ -189,7 +189,6 @@ setup(
'lpjsmin',
'Markdown',
'meliae',
- 'mock',
'oauth',
'oauthlib',
'oops',