diff --git a/src/pdm/framework/RESTClient.py b/src/pdm/framework/RESTClient.py index 32664bba..cfecba1c 100644 --- a/src/pdm/framework/RESTClient.py +++ b/src/pdm/framework/RESTClient.py @@ -170,10 +170,10 @@ def patch_client(target, test_client, base_uri='/'): # We import mock here as TestClient is only meant for use in the tests # If we import it globally, it'll break importing this module in # production. - import mock + import unittest.mock # We patch away the base class of the target, replacing it with # RESTClientTest instead. - patcher = mock.patch.object(target, '__bases__', (RESTClientTest, )) + patcher = unittest.mock.patch.object(target, '__bases__', (RESTClientTest, )) patcher.start() # is_local is required to prevent mock from attempting to delete # __bases__ when stop is called (which would throw an exception) diff --git a/test/pdm/CLI/test_usercommand.py b/test/pdm/CLI/test_usercommand.py index a6cfbfcc..394b1984 100644 --- a/test/pdm/CLI/test_usercommand.py +++ b/test/pdm/CLI/test_usercommand.py @@ -1,5 +1,5 @@ -import mock import unittest +import unittest.mock as mock import argparse import tempfile import datetime diff --git a/test/pdm/demo/test_DemoClient.py b/test/pdm/demo/test_DemoClient.py index 0245b4ab..323d87f4 100644 --- a/test/pdm/demo/test_DemoClient.py +++ b/test/pdm/demo/test_DemoClient.py @@ -1,7 +1,7 @@ #!/usr/bin/env python -import mock import unittest +import unittest.mock as mock from pdm.demo.DemoClient import DemoClient from pdm.demo.DemoService import DemoService diff --git a/test/pdm/framework/test_Database.py b/test/pdm/framework/test_Database.py index 5070121b..c5c05407 100644 --- a/test/pdm/framework/test_Database.py +++ b/test/pdm/framework/test_Database.py @@ -1,10 +1,10 @@ #!/usr/bin/env """ Framework database object tests. """ -import mock import json import datetime import unittest +import unittest.mock as mock from pdm.framework.Database import MemSafeSQLAlchemy from pdm.framework.Database import JSONMixin, JSONTableEncoder diff --git a/test/pdm/framework/test_RESTClient.py b/test/pdm/framework/test_RESTClient.py index 7b06165b..d1921f3c 100644 --- a/test/pdm/framework/test_RESTClient.py +++ b/test/pdm/framework/test_RESTClient.py @@ -2,8 +2,8 @@ """ Test RESTClient framework module. """ import json -import mock import unittest +import unittest.mock as mock import functools import requests diff --git a/test/pdm/framework/test_WSGIServer.py b/test/pdm/framework/test_WSGIServer.py index 2d0c5458..12a8ae17 100644 --- a/test/pdm/framework/test_WSGIServer.py +++ b/test/pdm/framework/test_WSGIServer.py @@ -1,8 +1,8 @@ #!/usr/bin/env python """ Tests for the WSGIServer module. """ -import mock import unittest +import unittest.mock as mock from pdm.framework.WSGIServer import WSGIAuth, WSGIServer diff --git a/test/pdm/site/test_SiteClient.py b/test/pdm/site/test_SiteClient.py index 85caaa95..5e81b44c 100644 --- a/test/pdm/site/test_SiteClient.py +++ b/test/pdm/site/test_SiteClient.py @@ -1,10 +1,10 @@ #!/usr/bin/env python """ Test SiteService client class. """ -import mock import logging import datetime import unittest +import unittest.mock as mock from pdm.site.SiteClient import SiteClient from pdm.site.SiteService import SiteService diff --git a/test/pdm/site/test_SiteService.py b/test/pdm/site/test_SiteService.py index 158dc34d..b71e3ab4 100644 --- a/test/pdm/site/test_SiteService.py +++ b/test/pdm/site/test_SiteService.py @@ -3,10 +3,10 @@ import copy import json -import mock import logging import datetime import unittest +import unittest.mock as mock from flask import current_app from pdm.site.SiteService import SiteService diff --git a/test/pdm/userservicedesk/test_HRClient.py b/test/pdm/userservicedesk/test_HRClient.py index a2b5b66b..5932cb23 100644 --- a/test/pdm/userservicedesk/test_HRClient.py +++ b/test/pdm/userservicedesk/test_HRClient.py @@ -4,7 +4,7 @@ import json import unittest -import mock +import unittest.mock as mock import datetime from pdm.userservicedesk.HRClient import HRClient diff --git a/test/pdm/userservicedesk/test_HRService.py b/test/pdm/userservicedesk/test_HRService.py index e9364663..698cae6b 100644 --- a/test/pdm/userservicedesk/test_HRService.py +++ b/test/pdm/userservicedesk/test_HRService.py @@ -2,7 +2,7 @@ import os import time import unittest -import mock +import unittest.mock as mock import copy import datetime import smtplib diff --git a/test/pdm/userservicedesk/test_TransferClient.py b/test/pdm/userservicedesk/test_TransferClient.py index a42ff10a..7e34ad90 100644 --- a/test/pdm/userservicedesk/test_TransferClient.py +++ b/test/pdm/userservicedesk/test_TransferClient.py @@ -1,5 +1,5 @@ -import mock import unittest +import unittest.mock as mock import datetime from pdm.userservicedesk.TransferClientFacade import TransferClientFacade from pdm.framework.FlaskWrapper import FlaskServer diff --git a/test/pdm/utils/test_X509.py b/test/pdm/utils/test_X509.py index 874f0417..d9c158a7 100644 --- a/test/pdm/utils/test_X509.py +++ b/test/pdm/utils/test_X509.py @@ -1,8 +1,8 @@ #!/usr/bin/env python import os -import mock import unittest +import unittest.mock as mock from functools import partial from pdm.utils.X509 import X509Utils diff --git a/test/pdm/utils/test_db.py b/test/pdm/utils/test_db.py index ba3d8f87..9a7bc2d5 100644 --- a/test/pdm/utils/test_db.py +++ b/test/pdm/utils/test_db.py @@ -1,8 +1,8 @@ #!/usr/bin/env python """ Test DB utils. """ -import mock import unittest +import unittest.mock as mock from pdm.utils.db import managed_session diff --git a/test/pdm/utils/test_lockfile.py b/test/pdm/utils/test_lockfile.py index 6b71aa1b..0a11cd0f 100644 --- a/test/pdm/utils/test_lockfile.py +++ b/test/pdm/utils/test_lockfile.py @@ -2,9 +2,9 @@ """ Test of utils lockfile module. """ import os -import mock import fcntl import unittest +import unittest.mock as mock from pdm.utils.lockfile import PIDLockFile, AlreadyLockedError diff --git a/test/pdm/utils/test_myproxy.py b/test/pdm/utils/test_myproxy.py index 6ccda589..1d38b0b8 100644 --- a/test/pdm/utils/test_myproxy.py +++ b/test/pdm/utils/test_myproxy.py @@ -1,8 +1,8 @@ #!/usr/bin/env python import os -import mock import unittest +import unittest.mock as mock from pdm.utils.myproxy import MyProxyUtils diff --git a/test/pdm/web/test_WebPageService.py b/test/pdm/web/test_WebPageService.py index 77dc975d..1ae223a9 100644 --- a/test/pdm/web/test_WebPageService.py +++ b/test/pdm/web/test_WebPageService.py @@ -1,7 +1,7 @@ #!/usr/bin/env python import unittest -import mock +import unittest.mock as mock from pdm.web.WebPageService import WebPageService from pdm.framework.FlaskWrapper import FlaskServer diff --git a/test/pdm/workqueue/scripts/test_stdout_dump_helper.py b/test/pdm/workqueue/scripts/test_stdout_dump_helper.py index 70394913..2a3c1c68 100644 --- a/test/pdm/workqueue/scripts/test_stdout_dump_helper.py +++ b/test/pdm/workqueue/scripts/test_stdout_dump_helper.py @@ -2,7 +2,7 @@ import unittest import logging -import mock +import unittest.mock as mock from pdm.workqueue.scripts import stdout_dump_helper diff --git a/test/pdm/workqueue/test_Worker.py b/test/pdm/workqueue/test_Worker.py index c65920b3..39632c5a 100644 --- a/test/pdm/workqueue/test_Worker.py +++ b/test/pdm/workqueue/test_Worker.py @@ -2,7 +2,7 @@ """ Test Worker module. """ import logging import unittest -import mock +import unittest.mock as mock from pdm.framework.FlaskWrapper import FlaskServer, jsonify from pdm.framework.RESTClient import RESTClientTest diff --git a/test/pdm/workqueue/test_WorkqueueClient.py b/test/pdm/workqueue/test_WorkqueueClient.py index 624cbcb8..f4345815 100644 --- a/test/pdm/workqueue/test_WorkqueueClient.py +++ b/test/pdm/workqueue/test_WorkqueueClient.py @@ -1,7 +1,7 @@ #!/usr/bin/env python """ Test WorkqueueClient module. """ import unittest -import mock +import unittest.mock as mock from pdm.framework.FlaskWrapper import FlaskServer, jsonify from pdm.framework.RESTClient import RESTClientTest diff --git a/test/pdm/workqueue/test_WorkqueueService.py b/test/pdm/workqueue/test_WorkqueueService.py index 382ad9d9..4dccfe15 100644 --- a/test/pdm/workqueue/test_WorkqueueService.py +++ b/test/pdm/workqueue/test_WorkqueueService.py @@ -3,7 +3,7 @@ import json import unittest from textwrap import dedent -import mock +import unittest.mock as mock from pdm.framework.FlaskWrapper import FlaskServer from pdm.workqueue.WorkqueueDB import JobType, JobStatus, JobProtocol diff --git a/tox.ini b/tox.ini index 62ab4415..c4ab1622 100644 --- a/tox.ini +++ b/tox.ini @@ -10,7 +10,6 @@ sitepackages=True # Standard unit testing + coverage [testenv:unit] deps= - mock pytest coverage commands= @@ -26,7 +25,6 @@ commands= [testenv:lint] deps= - mock pylint commands= /bin/bash test/bin/run_pylint.sh