From ff5f86f948eb7b34612967ba6f62d99b12b40204 Mon Sep 17 00:00:00 2001 From: Alexandre Detiste Date: Sun, 4 Oct 2026 14:11:34 +0200 Subject: [PATCH] drop usage of old "mock" external library mock has been merged into the standard library as unittest.mock since Python 3.7 --- kmip/tests/unit/core/objects/test_credentials.py | 2 +- kmip/tests/unit/core/test_config_helper.py | 3 +-- kmip/tests/unit/pie/test_client.py | 2 +- kmip/tests/unit/services/server/auth/test_slugs.py | 2 +- kmip/tests/unit/services/server/auth/test_utils.py | 2 +- kmip/tests/unit/services/server/crypto/test_engine.py | 2 +- kmip/tests/unit/services/server/test_config.py | 2 +- kmip/tests/unit/services/server/test_engine.py | 2 +- kmip/tests/unit/services/server/test_monitor.py | 2 +- kmip/tests/unit/services/server/test_server.py | 7 +------ kmip/tests/unit/services/server/test_session.py | 2 +- kmip/tests/unit/services/test_kmip_client.py | 2 +- kmip/tests/unit/services/test_kmip_protocol.py | 2 +- test-requirements.txt | 1 - 14 files changed, 13 insertions(+), 20 deletions(-) diff --git a/kmip/tests/unit/core/objects/test_credentials.py b/kmip/tests/unit/core/objects/test_credentials.py index 9ecd2e03..8b1d3a84 100644 --- a/kmip/tests/unit/core/objects/test_credentials.py +++ b/kmip/tests/unit/core/objects/test_credentials.py @@ -14,7 +14,7 @@ # under the License. import enum -import mock +from unittest import mock import testtools from kmip import enums diff --git a/kmip/tests/unit/core/test_config_helper.py b/kmip/tests/unit/core/test_config_helper.py index 76865999..ceec5718 100644 --- a/kmip/tests/unit/core/test_config_helper.py +++ b/kmip/tests/unit/core/test_config_helper.py @@ -19,8 +19,7 @@ import ConfigParser as configparser from testtools import TestCase -from mock import MagicMock -from mock import Mock +from unittest.mock import MagicMock, Mock from kmip.core.config_helper import ConfigHelper diff --git a/kmip/tests/unit/pie/test_client.py b/kmip/tests/unit/pie/test_client.py index 565d4f40..ee0a16aa 100644 --- a/kmip/tests/unit/pie/test_client.py +++ b/kmip/tests/unit/pie/test_client.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock import six import ssl import testtools diff --git a/kmip/tests/unit/services/server/auth/test_slugs.py b/kmip/tests/unit/services/server/auth/test_slugs.py index 49fa0c99..d5489d0e 100644 --- a/kmip/tests/unit/services/server/auth/test_slugs.py +++ b/kmip/tests/unit/services/server/auth/test_slugs.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock import requests import testtools diff --git a/kmip/tests/unit/services/server/auth/test_utils.py b/kmip/tests/unit/services/server/auth/test_utils.py index 2f96c226..950e8550 100644 --- a/kmip/tests/unit/services/server/auth/test_utils.py +++ b/kmip/tests/unit/services/server/auth/test_utils.py @@ -19,7 +19,7 @@ from cryptography.hazmat.primitives.asymmetric import rsa import datetime -import mock +from unittest import mock import ssl import testtools diff --git a/kmip/tests/unit/services/server/crypto/test_engine.py b/kmip/tests/unit/services/server/crypto/test_engine.py index edb52832..aefed9dd 100644 --- a/kmip/tests/unit/services/server/crypto/test_engine.py +++ b/kmip/tests/unit/services/server/crypto/test_engine.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock import pytest import testtools diff --git a/kmip/tests/unit/services/server/test_config.py b/kmip/tests/unit/services/server/test_config.py index e4b97508..ab213ece 100644 --- a/kmip/tests/unit/services/server/test_config.py +++ b/kmip/tests/unit/services/server/test_config.py @@ -14,7 +14,7 @@ # under the License. import logging -import mock +from unittest import mock import six from six.moves import configparser diff --git a/kmip/tests/unit/services/server/test_engine.py b/kmip/tests/unit/services/server/test_engine.py index 84deb436..8a32a88f 100644 --- a/kmip/tests/unit/services/server/test_engine.py +++ b/kmip/tests/unit/services/server/test_engine.py @@ -14,7 +14,7 @@ # under the License. import six -import mock +from unittest import mock import shutil import sqlalchemy diff --git a/kmip/tests/unit/services/server/test_monitor.py b/kmip/tests/unit/services/server/test_monitor.py index 7f4c4357..997055ad 100644 --- a/kmip/tests/unit/services/server/test_monitor.py +++ b/kmip/tests/unit/services/server/test_monitor.py @@ -14,7 +14,7 @@ # under the License. import logging -import mock +from unittest import mock import multiprocessing import os import shutil diff --git a/kmip/tests/unit/services/server/test_server.py b/kmip/tests/unit/services/server/test_server.py index 66ec8a36..10655619 100644 --- a/kmip/tests/unit/services/server/test_server.py +++ b/kmip/tests/unit/services/server/test_server.py @@ -14,15 +14,10 @@ # under the License. import logging - -try: - import unittest.mock as mock -except Exception: - import mock - import signal import socket import testtools +import unittest.mock as mock from kmip.core import exceptions from kmip.services import auth diff --git a/kmip/tests/unit/services/server/test_session.py b/kmip/tests/unit/services/server/test_session.py index b6661c5b..9ccd67d8 100644 --- a/kmip/tests/unit/services/server/test_session.py +++ b/kmip/tests/unit/services/server/test_session.py @@ -20,7 +20,7 @@ import datetime -import mock +from unittest import mock import socket import testtools import time diff --git a/kmip/tests/unit/services/test_kmip_client.py b/kmip/tests/unit/services/test_kmip_client.py index fa13a204..7c97ae47 100644 --- a/kmip/tests/unit/services/test_kmip_client.py +++ b/kmip/tests/unit/services/test_kmip_client.py @@ -66,7 +66,7 @@ from kmip.services.results import QueryResult from kmip.services.results import RekeyKeyPairResult -import mock +from unittest import mock import os import socket import ssl diff --git a/kmip/tests/unit/services/test_kmip_protocol.py b/kmip/tests/unit/services/test_kmip_protocol.py index e84e43a5..0ba6850e 100644 --- a/kmip/tests/unit/services/test_kmip_protocol.py +++ b/kmip/tests/unit/services/test_kmip_protocol.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -from mock import call, MagicMock +from unittest.mock import call, MagicMock from testtools import TestCase import binascii diff --git a/test-requirements.txt b/test-requirements.txt index 1ab6197d..c20669c3 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -3,7 +3,6 @@ pytest flake8 testtools fixtures -mock slugs sphinx PyYAML