From c735c75066c0f6d36ad3f0c24d4217fe9553c87a Mon Sep 17 00:00:00 2001 From: dineshbaburam91 Date: Fri, 3 May 2024 18:30:07 +0530 Subject: [PATCH] Updated mock to built-in unittest.mock --- development.txt | 3 +-- tests/unit/__init__.py | 2 +- tests/unit/factory/test_cfgtable.py | 2 +- tests/unit/factory/test_cmdtable.py | 2 +- tests/unit/factory/test_factory_loader.py | 2 +- tests/unit/factory/test_optable.py | 2 +- tests/unit/factory/test_table.py | 2 +- tests/unit/factory/test_to_json.py | 2 +- tests/unit/factory/test_view.py | 2 +- tests/unit/facts/test_current_re.py | 2 +- tests/unit/facts/test_domain.py | 2 +- tests/unit/facts/test_ethernet_mac_table.py | 2 +- tests/unit/facts/test_file_list.py | 2 +- tests/unit/facts/test_get_chassis_cluster_status.py | 2 +- tests/unit/facts/test_get_chassis_inventory.py | 2 +- tests/unit/facts/test_get_route_engine_information.py | 2 +- tests/unit/facts/test_get_software_information.py | 2 +- tests/unit/facts/test_get_virtual_chassis_information.py | 2 +- tests/unit/facts/test_ifd_style.py | 2 +- tests/unit/facts/test_iri_mapping.py | 2 +- tests/unit/facts/test_personality.py | 2 +- tests/unit/ofacts/test_chassis.py | 2 +- tests/unit/ofacts/test_domain.py | 2 +- tests/unit/ofacts/test_ifd_style.py | 2 +- tests/unit/ofacts/test_personality.py | 2 +- tests/unit/ofacts/test_routing_engines.py | 2 +- tests/unit/ofacts/test_srx_cluster.py | 2 +- tests/unit/ofacts/test_switch_style.py | 2 +- tests/unit/ofacts/test_swver.py | 2 +- tests/unit/test_console.py | 2 +- tests/unit/test_decorators.py | 2 +- tests/unit/test_device.py | 2 +- tests/unit/test_factcache.py | 2 +- tests/unit/test_junos.py | 2 +- tests/unit/test_jxml.py | 2 +- tests/unit/test_rpcmeta.py | 2 +- tests/unit/transport/test_serial.py | 2 +- tests/unit/transport/test_tty.py | 2 +- tests/unit/transport/test_tty_netconf.py | 2 +- tests/unit/transport/test_tty_ssh.py | 2 +- tests/unit/transport/test_tty_telnet.py | 2 +- tests/unit/utils/test_config.py | 2 +- tests/unit/utils/test_fs.py | 2 +- tests/unit/utils/test_ftp.py | 2 +- tests/unit/utils/test_scp.py | 2 +- tests/unit/utils/test_start_shell.py | 2 +- tests/unit/utils/test_sw.py | 2 +- tests/unit/utils/test_util.py | 2 +- 48 files changed, 48 insertions(+), 49 deletions(-) diff --git a/development.txt b/development.txt index f47e21ca4..24a995026 100644 --- a/development.txt +++ b/development.txt @@ -1,10 +1,9 @@ -r requirements.txt coverage # http://nedbatchelder.com/code/coverage/ -mock # http://www.voidspace.org.uk/python/mock/ nose2 # https://docs.nose2.io/en/latest/ pep8 # https://github.com/jcrocholl/pep8 pyflakes # https://launchpad.net/pyflakes coveralls # https://coveralls.io/ ntc_templates # user needs to explicitly install this -cryptography==3.2 \ No newline at end of file +cryptography==3.2 diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py index dd3388c69..1f868a92a 100644 --- a/tests/unit/__init__.py +++ b/tests/unit/__init__.py @@ -2,7 +2,7 @@ import sys import nose2 -from mock import patch +from unittest.mock import patch __author__ = "Nitin Kumar" __credits__ = "Jeremy Schulman" diff --git a/tests/unit/factory/test_cfgtable.py b/tests/unit/factory/test_cfgtable.py index 0ff618fde..9f15b4f45 100644 --- a/tests/unit/factory/test_cfgtable.py +++ b/tests/unit/factory/test_cfgtable.py @@ -13,7 +13,7 @@ from ncclient.manager import Manager, make_device_handler from ncclient.transport import SSHSession from lxml import etree -from mock import MagicMock, patch +from unittest.mock import MagicMock, patch from jnpr.junos.factory import loadyaml from jnpr.junos.factory.factory_loader import FactoryLoader diff --git a/tests/unit/factory/test_cmdtable.py b/tests/unit/factory/test_cmdtable.py index 177c6e6a0..76ca90829 100644 --- a/tests/unit/factory/test_cmdtable.py +++ b/tests/unit/factory/test_cmdtable.py @@ -10,7 +10,7 @@ from ncclient.manager import Manager, make_device_handler from ncclient.transport import SSHSession -from mock import MagicMock, patch +from unittest.mock import MagicMock, patch import yamlordereddictloader from jnpr.junos.factory.factory_loader import FactoryLoader import yaml diff --git a/tests/unit/factory/test_factory_loader.py b/tests/unit/factory/test_factory_loader.py index 4a9ac1624..a13f0f0ad 100644 --- a/tests/unit/factory/test_factory_loader.py +++ b/tests/unit/factory/test_factory_loader.py @@ -4,7 +4,7 @@ import unittest import nose2 from jnpr.junos.factory import FactoryLoader -from mock import patch +from unittest.mock import patch class TestFactoryLoader(unittest.TestCase): diff --git a/tests/unit/factory/test_optable.py b/tests/unit/factory/test_optable.py index 0c516a7d7..d699ada1b 100644 --- a/tests/unit/factory/test_optable.py +++ b/tests/unit/factory/test_optable.py @@ -19,7 +19,7 @@ from lxml import etree -from mock import patch +from unittest.mock import patch class TestFactoryOpTable(unittest.TestCase): diff --git a/tests/unit/factory/test_table.py b/tests/unit/factory/test_table.py index 3bcb5c1a7..0b1ff4c16 100644 --- a/tests/unit/factory/test_table.py +++ b/tests/unit/factory/test_table.py @@ -8,7 +8,7 @@ from jnpr.junos import Device from jnpr.junos.factory.table import Table -from mock import patch +from unittest.mock import patch from lxml import etree from jnpr.junos.op.phyport import PhyPortTable diff --git a/tests/unit/factory/test_to_json.py b/tests/unit/factory/test_to_json.py index 8d9204c05..95a9db18b 100644 --- a/tests/unit/factory/test_to_json.py +++ b/tests/unit/factory/test_to_json.py @@ -5,7 +5,7 @@ except ImportError: import unittest import nose2 -from mock import patch +from unittest.mock import patch import os import json diff --git a/tests/unit/factory/test_view.py b/tests/unit/factory/test_view.py index 455e3171a..30d48a588 100644 --- a/tests/unit/factory/test_view.py +++ b/tests/unit/factory/test_view.py @@ -3,7 +3,7 @@ import unittest import nose2 -from mock import MagicMock, patch +from unittest.mock import MagicMock, patch from jnpr.junos import Device from jnpr.junos.factory.view import View from jnpr.junos.op.phyport import PhyPortStatsTable, PhyPortStatsView diff --git a/tests/unit/facts/test_current_re.py b/tests/unit/facts/test_current_re.py index 3cc06eac9..085dc24f2 100644 --- a/tests/unit/facts/test_current_re.py +++ b/tests/unit/facts/test_current_re.py @@ -3,7 +3,7 @@ import unittest import nose2 -from mock import patch, MagicMock +from unittest.mock import patch, MagicMock import os from lxml import etree diff --git a/tests/unit/facts/test_domain.py b/tests/unit/facts/test_domain.py index 4e46e1438..201d0fca0 100644 --- a/tests/unit/facts/test_domain.py +++ b/tests/unit/facts/test_domain.py @@ -3,7 +3,7 @@ import unittest import nose2 -from mock import patch, MagicMock +from unittest.mock import patch, MagicMock import os from lxml import etree diff --git a/tests/unit/facts/test_ethernet_mac_table.py b/tests/unit/facts/test_ethernet_mac_table.py index 5e7be1e76..2dda45468 100644 --- a/tests/unit/facts/test_ethernet_mac_table.py +++ b/tests/unit/facts/test_ethernet_mac_table.py @@ -3,7 +3,7 @@ import unittest import nose2 -from mock import patch, MagicMock +from unittest.mock import patch, MagicMock import os from lxml import etree diff --git a/tests/unit/facts/test_file_list.py b/tests/unit/facts/test_file_list.py index 7ed58f5cf..89d16c01b 100644 --- a/tests/unit/facts/test_file_list.py +++ b/tests/unit/facts/test_file_list.py @@ -3,7 +3,7 @@ import unittest import nose2 -from mock import patch, MagicMock +from unittest.mock import patch, MagicMock import os from jnpr.junos import Device diff --git a/tests/unit/facts/test_get_chassis_cluster_status.py b/tests/unit/facts/test_get_chassis_cluster_status.py index 932c239c6..bebe589e3 100644 --- a/tests/unit/facts/test_get_chassis_cluster_status.py +++ b/tests/unit/facts/test_get_chassis_cluster_status.py @@ -3,7 +3,7 @@ import unittest import nose2 -from mock import patch, MagicMock +from unittest.mock import patch, MagicMock import os from lxml import etree diff --git a/tests/unit/facts/test_get_chassis_inventory.py b/tests/unit/facts/test_get_chassis_inventory.py index 3c3dba240..81b981e07 100644 --- a/tests/unit/facts/test_get_chassis_inventory.py +++ b/tests/unit/facts/test_get_chassis_inventory.py @@ -3,7 +3,7 @@ import unittest import nose2 -from mock import patch, MagicMock +from unittest.mock import patch, MagicMock import os from jnpr.junos import Device diff --git a/tests/unit/facts/test_get_route_engine_information.py b/tests/unit/facts/test_get_route_engine_information.py index 51c292559..2b607fa6c 100644 --- a/tests/unit/facts/test_get_route_engine_information.py +++ b/tests/unit/facts/test_get_route_engine_information.py @@ -3,7 +3,7 @@ import unittest import nose2 -from mock import patch, MagicMock +from unittest.mock import patch, MagicMock import os from lxml import etree diff --git a/tests/unit/facts/test_get_software_information.py b/tests/unit/facts/test_get_software_information.py index 6e455da2b..12b69ce28 100644 --- a/tests/unit/facts/test_get_software_information.py +++ b/tests/unit/facts/test_get_software_information.py @@ -3,7 +3,7 @@ import unittest import nose2 -from mock import patch, MagicMock +from unittest.mock import patch, MagicMock import os from lxml import etree diff --git a/tests/unit/facts/test_get_virtual_chassis_information.py b/tests/unit/facts/test_get_virtual_chassis_information.py index 2f13ccab1..e615c7a67 100644 --- a/tests/unit/facts/test_get_virtual_chassis_information.py +++ b/tests/unit/facts/test_get_virtual_chassis_information.py @@ -3,7 +3,7 @@ import unittest import nose2 -from mock import patch, MagicMock +from unittest.mock import patch, MagicMock import os import sys from lxml import etree diff --git a/tests/unit/facts/test_ifd_style.py b/tests/unit/facts/test_ifd_style.py index ddcfe48de..4fab144e0 100644 --- a/tests/unit/facts/test_ifd_style.py +++ b/tests/unit/facts/test_ifd_style.py @@ -3,7 +3,7 @@ import unittest import nose2 -from mock import patch, MagicMock +from unittest.mock import patch, MagicMock import os from lxml import etree diff --git a/tests/unit/facts/test_iri_mapping.py b/tests/unit/facts/test_iri_mapping.py index 66ba6ca44..d496db608 100644 --- a/tests/unit/facts/test_iri_mapping.py +++ b/tests/unit/facts/test_iri_mapping.py @@ -3,7 +3,7 @@ import unittest import nose2 -from mock import patch, MagicMock +from unittest.mock import patch, MagicMock import os from jnpr.junos import Device diff --git a/tests/unit/facts/test_personality.py b/tests/unit/facts/test_personality.py index e152777d2..9e4df83f8 100644 --- a/tests/unit/facts/test_personality.py +++ b/tests/unit/facts/test_personality.py @@ -3,7 +3,7 @@ import unittest import nose2 -from mock import patch, MagicMock +from unittest.mock import patch, MagicMock import os from jnpr.junos.exception import RpcError diff --git a/tests/unit/ofacts/test_chassis.py b/tests/unit/ofacts/test_chassis.py index d3f9beb62..351a23f93 100644 --- a/tests/unit/ofacts/test_chassis.py +++ b/tests/unit/ofacts/test_chassis.py @@ -3,7 +3,7 @@ import unittest import nose2 -from mock import patch, MagicMock +from unittest.mock import patch, MagicMock from lxml import etree import os diff --git a/tests/unit/ofacts/test_domain.py b/tests/unit/ofacts/test_domain.py index 87c303432..21f91d516 100644 --- a/tests/unit/ofacts/test_domain.py +++ b/tests/unit/ofacts/test_domain.py @@ -3,7 +3,7 @@ import unittest import nose2 -from mock import patch, MagicMock +from unittest.mock import patch, MagicMock from lxml import etree from jnpr.junos.ofacts.domain import facts_domain diff --git a/tests/unit/ofacts/test_ifd_style.py b/tests/unit/ofacts/test_ifd_style.py index d9ca28387..c664c803b 100644 --- a/tests/unit/ofacts/test_ifd_style.py +++ b/tests/unit/ofacts/test_ifd_style.py @@ -2,7 +2,7 @@ __credits__ = "Jeremy Schulman" import unittest -from mock import patch +from unittest.mock import patch import nose2 from jnpr.junos import Device diff --git a/tests/unit/ofacts/test_personality.py b/tests/unit/ofacts/test_personality.py index c37ee504c..85da1637e 100644 --- a/tests/unit/ofacts/test_personality.py +++ b/tests/unit/ofacts/test_personality.py @@ -2,7 +2,7 @@ __credits__ = "Jeremy Schulman" import unittest -from mock import patch +from unittest.mock import patch import nose2 from jnpr.junos import Device diff --git a/tests/unit/ofacts/test_routing_engines.py b/tests/unit/ofacts/test_routing_engines.py index a7f068205..a5d3bd488 100644 --- a/tests/unit/ofacts/test_routing_engines.py +++ b/tests/unit/ofacts/test_routing_engines.py @@ -3,7 +3,7 @@ import unittest import nose2 -from mock import patch, MagicMock +from unittest.mock import patch, MagicMock import os import sys diff --git a/tests/unit/ofacts/test_srx_cluster.py b/tests/unit/ofacts/test_srx_cluster.py index ce07983b4..6832c9366 100644 --- a/tests/unit/ofacts/test_srx_cluster.py +++ b/tests/unit/ofacts/test_srx_cluster.py @@ -3,7 +3,7 @@ import unittest import nose2 -from mock import patch +from unittest.mock import patch import os from jnpr.junos import Device diff --git a/tests/unit/ofacts/test_switch_style.py b/tests/unit/ofacts/test_switch_style.py index 83dfcb5a8..4e4add378 100644 --- a/tests/unit/ofacts/test_switch_style.py +++ b/tests/unit/ofacts/test_switch_style.py @@ -2,7 +2,7 @@ __credits__ = "Jeremy Schulman" import unittest -from mock import patch +from unittest.mock import patch import nose2 from jnpr.junos import Device diff --git a/tests/unit/ofacts/test_swver.py b/tests/unit/ofacts/test_swver.py index 59e52fa07..65b36659b 100644 --- a/tests/unit/ofacts/test_swver.py +++ b/tests/unit/ofacts/test_swver.py @@ -6,7 +6,7 @@ except ImportError: import unittest import nose2 -from mock import patch, MagicMock +from unittest.mock import patch, MagicMock import os from jnpr.junos import Device diff --git a/tests/unit/test_console.py b/tests/unit/test_console.py index 3b8769715..de28e8cb3 100644 --- a/tests/unit/test_console.py +++ b/tests/unit/test_console.py @@ -4,7 +4,7 @@ import unittest from jnpr.junos.utils.config import Config import nose2 -from mock import patch, MagicMock, call +from unittest.mock import patch, MagicMock, call import re import sys import os diff --git a/tests/unit/test_decorators.py b/tests/unit/test_decorators.py index aefde05e4..aa9a0bb6a 100644 --- a/tests/unit/test_decorators.py +++ b/tests/unit/test_decorators.py @@ -12,7 +12,7 @@ from jnpr.junos.decorators import timeoutDecorator, normalizeDecorator from jnpr.junos.decorators import ignoreWarnDecorator -from mock import patch, MagicMock, PropertyMock, call +from unittest.mock import patch, MagicMock, PropertyMock, call from ncclient.operations.rpc import RPCError from ncclient.manager import Manager, make_device_handler diff --git a/tests/unit/test_device.py b/tests/unit/test_device.py index 3c8c6604f..1f8a97ebc 100644 --- a/tests/unit/test_device.py +++ b/tests/unit/test_device.py @@ -3,7 +3,7 @@ except ImportError: import unittest import nose2 -from mock import MagicMock, patch, mock_open, call +from unittest.mock import MagicMock, patch, mock_open, call import os from lxml import etree import sys diff --git a/tests/unit/test_factcache.py b/tests/unit/test_factcache.py index b173c39dd..7f63fed45 100644 --- a/tests/unit/test_factcache.py +++ b/tests/unit/test_factcache.py @@ -3,7 +3,7 @@ except ImportError: import unittest import nose2 -from mock import patch, MagicMock, call +from unittest.mock import patch, MagicMock, call from jnpr.junos.exception import FactLoopError from jnpr.junos import Device diff --git a/tests/unit/test_junos.py b/tests/unit/test_junos.py index ca1bde283..e72c6a5c8 100644 --- a/tests/unit/test_junos.py +++ b/tests/unit/test_junos.py @@ -4,7 +4,7 @@ import sys import nose2 -from mock import patch +from unittest.mock import patch __author__ = "Nitin Kumar" __credits__ = "Jeremy Schulman" diff --git a/tests/unit/test_jxml.py b/tests/unit/test_jxml.py index de4b893e4..26268f025 100644 --- a/tests/unit/test_jxml.py +++ b/tests/unit/test_jxml.py @@ -2,7 +2,7 @@ import unittest from io import StringIO import nose2 -from mock import patch +from unittest.mock import patch from jnpr.junos.jxml import ( NAME, INSERT, diff --git a/tests/unit/test_rpcmeta.py b/tests/unit/test_rpcmeta.py index 7b4f0579e..be91cee2c 100644 --- a/tests/unit/test_rpcmeta.py +++ b/tests/unit/test_rpcmeta.py @@ -10,7 +10,7 @@ from ncclient.transport import SSHSession from jnpr.junos.exception import JSONLoadError -from mock import patch, MagicMock, call +from unittest.mock import patch, MagicMock, call from lxml import etree __author__ = "Nitin Kumar, Rick Sherman" diff --git a/tests/unit/transport/test_serial.py b/tests/unit/transport/test_serial.py index 570213baf..310205737 100644 --- a/tests/unit/transport/test_serial.py +++ b/tests/unit/transport/test_serial.py @@ -3,7 +3,7 @@ except ImportError: import unittest import nose2 -from mock import MagicMock, patch +from unittest.mock import MagicMock, patch import sys import six diff --git a/tests/unit/transport/test_tty.py b/tests/unit/transport/test_tty.py index 87f1c2b51..ad9997d12 100644 --- a/tests/unit/transport/test_tty.py +++ b/tests/unit/transport/test_tty.py @@ -6,7 +6,7 @@ import unittest import nose2 -from mock import MagicMock, patch +from unittest.mock import MagicMock, patch from jnpr.junos.transport.tty import Terminal from jnpr.junos import exception as EzErrors diff --git a/tests/unit/transport/test_tty_netconf.py b/tests/unit/transport/test_tty_netconf.py index 612d0164a..ba10bfa69 100644 --- a/tests/unit/transport/test_tty_netconf.py +++ b/tests/unit/transport/test_tty_netconf.py @@ -3,7 +3,7 @@ except ImportError: import unittest import nose2 -from mock import MagicMock, patch +from unittest.mock import MagicMock, patch from jnpr.junos.transport.tty_netconf import tty_netconf diff --git a/tests/unit/transport/test_tty_ssh.py b/tests/unit/transport/test_tty_ssh.py index 62729c7ac..8170081b4 100644 --- a/tests/unit/transport/test_tty_ssh.py +++ b/tests/unit/transport/test_tty_ssh.py @@ -6,7 +6,7 @@ except ImportError: import unittest import nose2 -from mock import MagicMock, patch +from unittest.mock import MagicMock, patch from jnpr.junos.transport.tty_ssh import SSH diff --git a/tests/unit/transport/test_tty_telnet.py b/tests/unit/transport/test_tty_telnet.py index 2030a61ff..1f7949325 100644 --- a/tests/unit/transport/test_tty_telnet.py +++ b/tests/unit/transport/test_tty_telnet.py @@ -5,7 +5,7 @@ except ImportError: import unittest import nose2 -from mock import MagicMock, patch +from unittest.mock import MagicMock, patch from jnpr.junos.transport.tty_telnet import Telnet import six diff --git a/tests/unit/utils/test_config.py b/tests/unit/utils/test_config.py index 2dbd69101..0ff7f2c7f 100644 --- a/tests/unit/utils/test_config.py +++ b/tests/unit/utils/test_config.py @@ -19,7 +19,7 @@ from ncclient.transport import SSHSession from ncclient.operations import RPCError, RPCReply -from mock import MagicMock, patch +from unittest.mock import MagicMock, patch from lxml import etree import os diff --git a/tests/unit/utils/test_fs.py b/tests/unit/utils/test_fs.py index bc03e623b..c6591f470 100644 --- a/tests/unit/utils/test_fs.py +++ b/tests/unit/utils/test_fs.py @@ -9,7 +9,7 @@ from jnpr.junos.utils.fs import FS from jnpr.junos.exception import RpcError -from mock import patch, MagicMock, call +from unittest.mock import patch, MagicMock, call from lxml import etree __author__ = "Nitin Kumar, Rick Sherman" diff --git a/tests/unit/utils/test_ftp.py b/tests/unit/utils/test_ftp.py index fcc0606e5..6623dbcc6 100644 --- a/tests/unit/utils/test_ftp.py +++ b/tests/unit/utils/test_ftp.py @@ -7,7 +7,7 @@ from jnpr.junos import Device import jnpr.junos.utils.ftp -from mock import patch +from unittest.mock import patch if sys.version < "3": builtin_string = "__builtin__" diff --git a/tests/unit/utils/test_scp.py b/tests/unit/utils/test_scp.py index 517e802ca..de8a3836c 100644 --- a/tests/unit/utils/test_scp.py +++ b/tests/unit/utils/test_scp.py @@ -8,7 +8,7 @@ from jnpr.junos import Device from jnpr.junos.utils.scp import SCP -from mock import patch +from unittest.mock import patch __author__ = "Rick Sherman, Nitin Kumar" __credits__ = "Jeremy Schulman" diff --git a/tests/unit/utils/test_start_shell.py b/tests/unit/utils/test_start_shell.py index 0034f2b3e..4f3ecd9e8 100644 --- a/tests/unit/utils/test_start_shell.py +++ b/tests/unit/utils/test_start_shell.py @@ -4,7 +4,7 @@ from jnpr.junos import Device from jnpr.junos.utils.start_shell import StartShell -from mock import patch, MagicMock, call +from unittest.mock import patch, MagicMock, call __author__ = "Rick Sherman" __credits__ = "Jeremy Schulman, Nitin Kumar" diff --git a/tests/unit/utils/test_sw.py b/tests/unit/utils/test_sw.py index 1f669b078..ad6cc773b 100644 --- a/tests/unit/utils/test_sw.py +++ b/tests/unit/utils/test_sw.py @@ -16,7 +16,7 @@ from ncclient.manager import Manager, make_device_handler from ncclient.transport import SSHSession from lxml import etree -from mock import patch, MagicMock, call, mock_open +from unittest.mock import patch, MagicMock, call, mock_open if sys.version < "3": builtin_string = "__builtin__" diff --git a/tests/unit/utils/test_util.py b/tests/unit/utils/test_util.py index 86f5cb644..0c5385a93 100644 --- a/tests/unit/utils/test_util.py +++ b/tests/unit/utils/test_util.py @@ -7,7 +7,7 @@ from jnpr.junos import Device from jnpr.junos.utils.util import Util -from mock import patch +from unittest.mock import patch class TestUtil(unittest.TestCase):