From 4f64630e7b38462365082affd8d0e315b61d297b Mon Sep 17 00:00:00 2001 From: chidanandpujar Date: Mon, 6 Nov 2023 19:46:08 +0530 Subject: [PATCH 01/28] python3.12 support --- lib/jnpr/junos/utils/scp.py | 2 +- requirements.txt | 2 +- versioneer.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/jnpr/junos/utils/scp.py b/lib/jnpr/junos/utils/scp.py index 6bfc727b3..36f179cab 100644 --- a/lib/jnpr/junos/utils/scp.py +++ b/lib/jnpr/junos/utils/scp.py @@ -43,7 +43,7 @@ def __init__(self, junos, **scpargs): # User case also define progress with 3 params, the way scp module # expects. Function will take path, total size, transferred. # https://github.com/jbardin/scp.py/blob/master/scp.py#L97 - spec = inspect.getargspec(self._user_progress) + spec = inspect.getfullargspec(self._user_progress) if (len(spec.args) == 3 and spec.args[0] != "self") or ( len(spec.args) == 4 and spec.args[0] == "self" ): diff --git a/requirements.txt b/requirements.txt index 798c7b32f..cb652323e 100755 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ lxml>=3.2.4 # ncclient version 0.6.10 has issues with PyEZ(junos-eznc) and needs to be avoided -ncclient==0.6.13 +ncclient==0.6.15 paramiko>=1.15.2 scp>=0.7.0 jinja2>=2.7.1 diff --git a/versioneer.py b/versioneer.py index 2b5454051..8b24e239b 100644 --- a/versioneer.py +++ b/versioneer.py @@ -343,9 +343,9 @@ def get_config_from_root(root): # configparser.NoOptionError (if it lacks "VCS="). See the docstring at # the top of versioneer.py for instructions on writing your setup.cfg . setup_cfg = os.path.join(root, "setup.cfg") - parser = configparser.SafeConfigParser() + parser = configparser.ConfigParser() with open(setup_cfg, "r") as f: - parser.readfp(f) + parser.read_file(f) VCS = parser.get("versioneer", "VCS") # mandatory def get(parser, name): From 783aa34f57b5572a25bf74aa3bf55e4a1ac43e85 Mon Sep 17 00:00:00 2001 From: chidanandpujar Date: Fri, 17 Nov 2023 14:00:52 +0530 Subject: [PATCH 02/28] python3.12 support --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index cb652323e..c18bc21d0 100755 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ lxml>=3.2.4 # ncclient version 0.6.10 has issues with PyEZ(junos-eznc) and needs to be avoided -ncclient==0.6.15 +ncclient>=0.6.15 paramiko>=1.15.2 scp>=0.7.0 jinja2>=2.7.1 From fcfed1c81697dba35760fb6206ea93a6be989ea0 Mon Sep 17 00:00:00 2001 From: chidanandpujar Date: Fri, 17 Nov 2023 22:05:59 +0530 Subject: [PATCH 03/28] python3.12 support --- tests/unit/__init__.py | 6 +++--- tests/unit/factory/test_cfgtable.py | 4 ++-- tests/unit/factory/test_cmdtable.py | 4 ++-- tests/unit/factory/test_factory_cls.py | 4 ++-- tests/unit/factory/test_factory_loader.py | 4 ++-- tests/unit/factory/test_optable.py | 4 ++-- tests/unit/factory/test_table.py | 4 ++-- tests/unit/factory/test_to_json.py | 4 ++-- tests/unit/factory/test_view.py | 4 ++-- tests/unit/factory/test_view_fields.py | 4 ++-- tests/unit/facts/test__init__.py | 4 ++-- tests/unit/facts/test_current_re.py | 4 ++-- tests/unit/facts/test_domain.py | 4 ++-- tests/unit/facts/test_ethernet_mac_table.py | 4 ++-- tests/unit/facts/test_file_list.py | 4 ++-- tests/unit/facts/test_get_chassis_cluster_status.py | 4 ++-- tests/unit/facts/test_get_chassis_inventory.py | 4 ++-- tests/unit/facts/test_get_route_engine_information.py | 4 ++-- tests/unit/facts/test_get_software_information.py | 4 ++-- tests/unit/facts/test_get_virtual_chassis_information.py | 4 ++-- tests/unit/facts/test_ifd_style.py | 4 ++-- tests/unit/facts/test_iri_mapping.py | 4 ++-- tests/unit/facts/test_personality.py | 4 ++-- tests/unit/facts/test_swver.py | 4 ++-- tests/unit/ofacts/test_chassis.py | 4 ++-- tests/unit/ofacts/test_domain.py | 4 ++-- tests/unit/ofacts/test_ifd_style.py | 4 ++-- tests/unit/ofacts/test_personality.py | 4 ++-- tests/unit/ofacts/test_routing_engines.py | 4 ++-- tests/unit/ofacts/test_srx_cluster.py | 4 ++-- tests/unit/ofacts/test_switch_style.py | 4 ++-- tests/unit/ofacts/test_swver.py | 4 ++-- tests/unit/test_decorators.py | 4 ++-- tests/unit/test_device.py | 5 ++--- tests/unit/test_exception.py | 4 ++-- tests/unit/test_factcache.py | 4 ++-- tests/unit/test_junos.py | 8 ++++---- tests/unit/test_jxml.py | 4 ++-- tests/unit/test_rpcmeta.py | 4 ++-- tests/unit/transport/test_serial.py | 6 +++--- tests/unit/transport/test_tty.py | 4 ++-- tests/unit/transport/test_tty_netconf.py | 4 ++-- tests/unit/transport/test_tty_ssh.py | 4 ++-- tests/unit/transport/test_tty_telnet.py | 4 ++-- tests/unit/utils/test_config.py | 4 ++-- tests/unit/utils/test_fs.py | 4 ++-- tests/unit/utils/test_ftp.py | 4 ++-- tests/unit/utils/test_scp.py | 4 ++-- tests/unit/utils/test_start_shell.py | 4 ++-- tests/unit/utils/test_sw.py | 4 ++-- tests/unit/utils/test_util.py | 4 ++-- 51 files changed, 106 insertions(+), 107 deletions(-) diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py index 07bc7e0da..7329bda2b 100644 --- a/tests/unit/__init__.py +++ b/tests/unit/__init__.py @@ -1,7 +1,7 @@ import unittest import sys -from nose.plugins.attrib import attr +import nose2 from mock import patch __author__ = "Nitin Kumar" @@ -11,7 +11,7 @@ @attr("unit") class TestJunosInit(unittest.TestCase): def test_warning(self): - with patch.object(sys.modules["sys"], "version_info", (2, 6, 3)) as mock_sys: + with patch.object(sys.modules["sys"], "version_info", (2, 6, 8)) as mock_sys: from jnpr import junos - self.assertEqual(mock_sys, (2, 6, 3)) + self.assertEqual(mock_sys, (2, 6, 8)) diff --git a/tests/unit/factory/test_cfgtable.py b/tests/unit/factory/test_cfgtable.py index f9e6eadd3..574333945 100644 --- a/tests/unit/factory/test_cfgtable.py +++ b/tests/unit/factory/test_cfgtable.py @@ -5,7 +5,7 @@ import os import sys -from nose.plugins.attrib import attr +import nose2 import yaml from jnpr.junos import Device @@ -85,7 +85,7 @@ globals().update(FactoryLoader().load(yaml.load(yaml_bgp_data, Loader=yaml.FullLoader))) -@attr("unit") + @unittest.skipIf(sys.platform == "win32", "will work for windows in coming days") class TestFactoryCfgTable(unittest.TestCase): @patch("ncclient.manager.connect") diff --git a/tests/unit/factory/test_cmdtable.py b/tests/unit/factory/test_cmdtable.py index d74e02352..9944a41dd 100644 --- a/tests/unit/factory/test_cmdtable.py +++ b/tests/unit/factory/test_cmdtable.py @@ -3,7 +3,7 @@ import unittest import os -from nose.plugins.attrib import attr +import nose2 from jnpr.junos import Device from jnpr.junos.exception import RpcError @@ -17,7 +17,7 @@ import json -@attr("unit") + class TestFactoryCMDTable(unittest.TestCase): @patch("ncclient.manager.connect") def setUp(self, mock_connect): diff --git a/tests/unit/factory/test_factory_cls.py b/tests/unit/factory/test_factory_cls.py index a86a0bb44..13bb3cb81 100644 --- a/tests/unit/factory/test_factory_cls.py +++ b/tests/unit/factory/test_factory_cls.py @@ -2,13 +2,13 @@ __credits__ = "Jeremy Schulman" import unittest -from nose.plugins.attrib import attr +import nose2 from jnpr.junos.factory.factory_cls import FactoryCfgTable, FactoryOpTable from jnpr.junos.factory.factory_cls import FactoryTable, FactoryView -@attr("unit") + class TestFactoryCls(unittest.TestCase): def test_factory_cls_cfgtable(self): t = FactoryCfgTable() diff --git a/tests/unit/factory/test_factory_loader.py b/tests/unit/factory/test_factory_loader.py index d126e10e9..68e4738b0 100644 --- a/tests/unit/factory/test_factory_loader.py +++ b/tests/unit/factory/test_factory_loader.py @@ -2,12 +2,12 @@ __credits__ = "Jeremy Schulman" import unittest -from nose.plugins.attrib import attr +import nose2 from jnpr.junos.factory import FactoryLoader from mock import patch -@attr("unit") + class TestFactoryLoader(unittest.TestCase): def setUp(self): self.fl = FactoryLoader() diff --git a/tests/unit/factory/test_optable.py b/tests/unit/factory/test_optable.py index 996541221..532e57c06 100644 --- a/tests/unit/factory/test_optable.py +++ b/tests/unit/factory/test_optable.py @@ -5,7 +5,7 @@ import os import yaml import json -from nose.plugins.attrib import attr +import nose2 from jnpr.junos import Device from jnpr.junos.op.phyport import PhyPortStatsTable @@ -22,7 +22,7 @@ from mock import patch -@attr("unit") + class TestFactoryOpTable(unittest.TestCase): @patch("ncclient.manager.connect") def setUp(self, mock_connect): diff --git a/tests/unit/factory/test_table.py b/tests/unit/factory/test_table.py index 870a723ed..9546a8a69 100644 --- a/tests/unit/factory/test_table.py +++ b/tests/unit/factory/test_table.py @@ -2,7 +2,7 @@ __credits__ = "Jeremy Schulman" import unittest -from nose.plugins.attrib import attr +import nose2 import os from jnpr.junos import Device @@ -23,7 +23,7 @@ builtin_string = "builtins" -@attr("unit") + class TestFactoryTable(unittest.TestCase): @patch("ncclient.manager.connect") def setUp(self, mock_connect): diff --git a/tests/unit/factory/test_to_json.py b/tests/unit/factory/test_to_json.py index b6feb2cac..83058b6a8 100644 --- a/tests/unit/factory/test_to_json.py +++ b/tests/unit/factory/test_to_json.py @@ -4,7 +4,7 @@ import unittest2 as unittest except ImportError: import unittest -from nose.plugins.attrib import attr +import nose2 from mock import patch import os import json @@ -21,7 +21,7 @@ from ncclient.operations.rpc import RPCReply -@attr("unit") + class TestToJson(unittest.TestCase): @patch("ncclient.manager.connect") def setUp(self, mock_connect): diff --git a/tests/unit/factory/test_view.py b/tests/unit/factory/test_view.py index 2548712a1..392bd307c 100644 --- a/tests/unit/factory/test_view.py +++ b/tests/unit/factory/test_view.py @@ -2,7 +2,7 @@ __credits__ = "Jeremy Schulman" import unittest -from nose.plugins.attrib import attr +import nose2 from mock import MagicMock, patch from jnpr.junos import Device from jnpr.junos.factory.view import View @@ -10,7 +10,7 @@ from lxml import etree -@attr("unit") + class TestFactoryView(unittest.TestCase): def setUp(self): self.dev = Device( diff --git a/tests/unit/factory/test_view_fields.py b/tests/unit/factory/test_view_fields.py index 59ad9d2cf..cf4102bb8 100644 --- a/tests/unit/factory/test_view_fields.py +++ b/tests/unit/factory/test_view_fields.py @@ -2,12 +2,12 @@ __credits__ = "Jeremy Schulman" import unittest -from nose.plugins.attrib import attr +import nose2 from jnpr.junos.factory.viewfields import ViewFields -@attr("unit") + class TestFactoryViewFields(unittest.TestCase): def setUp(self): self.vf = ViewFields() diff --git a/tests/unit/facts/test__init__.py b/tests/unit/facts/test__init__.py index 5327e63bb..b22798ab0 100644 --- a/tests/unit/facts/test__init__.py +++ b/tests/unit/facts/test__init__.py @@ -5,14 +5,14 @@ import unittest2 as unittest except ImportError: import unittest -from nose.plugins.attrib import attr +import nose2 import importlib import sys import jnpr.junos.facts -@attr("unit") + class TestFactInitialization(unittest.TestCase): def test_duplicate_facts(self): module = importlib.import_module("tests.unit.facts.dupe_foo1") diff --git a/tests/unit/facts/test_current_re.py b/tests/unit/facts/test_current_re.py index a36f1d7a5..8cbf0e531 100644 --- a/tests/unit/facts/test_current_re.py +++ b/tests/unit/facts/test_current_re.py @@ -2,7 +2,7 @@ __credits__ = "Jeremy Schulman, Nitin Kumar" import unittest -from nose.plugins.attrib import attr +import nose2 from mock import patch, MagicMock import os from lxml import etree @@ -14,7 +14,7 @@ from ncclient.transport import SSHSession -@attr("unit") + class TestCurrentRe(unittest.TestCase): @patch("ncclient.manager.connect") def setUp(self, mock_connect): diff --git a/tests/unit/facts/test_domain.py b/tests/unit/facts/test_domain.py index e75b8e2dc..525c05a1a 100644 --- a/tests/unit/facts/test_domain.py +++ b/tests/unit/facts/test_domain.py @@ -2,7 +2,7 @@ __credits__ = "Jeremy Schulman, Nitin Kumar" import unittest -from nose.plugins.attrib import attr +import nose2 from mock import patch, MagicMock import os from lxml import etree @@ -14,7 +14,7 @@ from ncclient.transport import SSHSession -@attr("unit") + class TestDomain(unittest.TestCase): @patch("ncclient.manager.connect") def setUp(self, mock_connect): diff --git a/tests/unit/facts/test_ethernet_mac_table.py b/tests/unit/facts/test_ethernet_mac_table.py index f5d1501b3..f63a95e85 100644 --- a/tests/unit/facts/test_ethernet_mac_table.py +++ b/tests/unit/facts/test_ethernet_mac_table.py @@ -2,7 +2,7 @@ __credits__ = "Jeremy Schulman, Nitin Kumar" import unittest -from nose.plugins.attrib import attr +import nose2 from mock import patch, MagicMock import os from lxml import etree @@ -14,7 +14,7 @@ from ncclient.transport import SSHSession -@attr("unit") + class TestEthernetMacTable(unittest.TestCase): @patch("ncclient.manager.connect") def setUp(self, mock_connect): diff --git a/tests/unit/facts/test_file_list.py b/tests/unit/facts/test_file_list.py index 860132f62..61d7b4e68 100644 --- a/tests/unit/facts/test_file_list.py +++ b/tests/unit/facts/test_file_list.py @@ -2,7 +2,7 @@ __credits__ = "Jeremy Schulman, Nitin Kumar" import unittest -from nose.plugins.attrib import attr +import nose2 from mock import patch, MagicMock import os @@ -12,7 +12,7 @@ from ncclient.transport import SSHSession -@attr("unit") + class TestFileList(unittest.TestCase): @patch("ncclient.manager.connect") def setUp(self, mock_connect): diff --git a/tests/unit/facts/test_get_chassis_cluster_status.py b/tests/unit/facts/test_get_chassis_cluster_status.py index 993e81809..c32751f52 100644 --- a/tests/unit/facts/test_get_chassis_cluster_status.py +++ b/tests/unit/facts/test_get_chassis_cluster_status.py @@ -2,7 +2,7 @@ __credits__ = "Jeremy Schulman, Nitin Kumar" import unittest -from nose.plugins.attrib import attr +import nose2 from mock import patch, MagicMock import os from lxml import etree @@ -14,7 +14,7 @@ from ncclient.transport import SSHSession -@attr("unit") + class TestGetChassisClusterStatus(unittest.TestCase): @patch("ncclient.manager.connect") def setUp(self, mock_connect): diff --git a/tests/unit/facts/test_get_chassis_inventory.py b/tests/unit/facts/test_get_chassis_inventory.py index 707206f92..e86fa502c 100644 --- a/tests/unit/facts/test_get_chassis_inventory.py +++ b/tests/unit/facts/test_get_chassis_inventory.py @@ -2,7 +2,7 @@ __credits__ = "Jeremy Schulman, Nitin Kumar" import unittest -from nose.plugins.attrib import attr +import nose2 from mock import patch, MagicMock import os @@ -12,7 +12,7 @@ from ncclient.transport import SSHSession -@attr("unit") + class TestChassis(unittest.TestCase): @patch("ncclient.manager.connect") def setUp(self, mock_connect): diff --git a/tests/unit/facts/test_get_route_engine_information.py b/tests/unit/facts/test_get_route_engine_information.py index ca26bf8a6..4680643ab 100644 --- a/tests/unit/facts/test_get_route_engine_information.py +++ b/tests/unit/facts/test_get_route_engine_information.py @@ -2,7 +2,7 @@ __credits__ = "Jeremy Schulman, Nitin Kumar" import unittest -from nose.plugins.attrib import attr +import nose2 from mock import patch, MagicMock import os from lxml import etree @@ -13,7 +13,7 @@ from ncclient.transport import SSHSession -@attr("unit") + class TestGetRouteEngineInformation(unittest.TestCase): @patch("ncclient.manager.connect") def setUp(self, mock_connect): diff --git a/tests/unit/facts/test_get_software_information.py b/tests/unit/facts/test_get_software_information.py index 2b285dfb3..84882150c 100644 --- a/tests/unit/facts/test_get_software_information.py +++ b/tests/unit/facts/test_get_software_information.py @@ -2,7 +2,7 @@ __credits__ = "Jeremy Schulman, Nitin Kumar" import unittest -from nose.plugins.attrib import attr +import nose2 from mock import patch, MagicMock import os from lxml import etree @@ -14,7 +14,7 @@ from ncclient.transport import SSHSession -@attr("unit") + class TestGetSoftwareInformation(unittest.TestCase): @patch("ncclient.manager.connect") def setUp(self, mock_connect): diff --git a/tests/unit/facts/test_get_virtual_chassis_information.py b/tests/unit/facts/test_get_virtual_chassis_information.py index fd85de956..1f455030d 100644 --- a/tests/unit/facts/test_get_virtual_chassis_information.py +++ b/tests/unit/facts/test_get_virtual_chassis_information.py @@ -2,7 +2,7 @@ __credits__ = "Jeremy Schulman, Nitin Kumar" import unittest -from nose.plugins.attrib import attr +import nose2 from mock import patch, MagicMock import os import sys @@ -15,7 +15,7 @@ from ncclient.transport import SSHSession -@attr("unit") + class TestGetVirtualChassisInformation(unittest.TestCase): @patch("ncclient.manager.connect") def setUp(self, mock_connect): diff --git a/tests/unit/facts/test_ifd_style.py b/tests/unit/facts/test_ifd_style.py index 7bcbd02d3..7ecc305a6 100644 --- a/tests/unit/facts/test_ifd_style.py +++ b/tests/unit/facts/test_ifd_style.py @@ -2,7 +2,7 @@ __credits__ = "Jeremy Schulman, Nitin Kumar" import unittest -from nose.plugins.attrib import attr +import nose2 from mock import patch, MagicMock import os from lxml import etree @@ -14,7 +14,7 @@ from ncclient.transport import SSHSession -@attr("unit") + class TestIfdStyle(unittest.TestCase): @patch("ncclient.manager.connect") def setUp(self, mock_connect): diff --git a/tests/unit/facts/test_iri_mapping.py b/tests/unit/facts/test_iri_mapping.py index 1d73e5258..654ac94e8 100644 --- a/tests/unit/facts/test_iri_mapping.py +++ b/tests/unit/facts/test_iri_mapping.py @@ -2,7 +2,7 @@ __credits__ = "Jeremy Schulman, Nitin Kumar" import unittest -from nose.plugins.attrib import attr +import nose2 from mock import patch, MagicMock import os @@ -12,7 +12,7 @@ from ncclient.transport import SSHSession -@attr("unit") + class TestIriMapping(unittest.TestCase): @patch("ncclient.manager.connect") def setUp(self, mock_connect): diff --git a/tests/unit/facts/test_personality.py b/tests/unit/facts/test_personality.py index 59de7118e..4598923b2 100644 --- a/tests/unit/facts/test_personality.py +++ b/tests/unit/facts/test_personality.py @@ -2,7 +2,7 @@ __credits__ = "Jeremy Schulman, Nitin Kumar" import unittest -from nose.plugins.attrib import attr +import nose2 from mock import patch, MagicMock import os from jnpr.junos.exception import RpcError @@ -13,7 +13,7 @@ from ncclient.transport import SSHSession -@attr("unit") + class TestPersonality(unittest.TestCase): @patch("ncclient.manager.connect") def setUp(self, mock_connect): diff --git a/tests/unit/facts/test_swver.py b/tests/unit/facts/test_swver.py index b9ad9edb5..7d7bec44e 100644 --- a/tests/unit/facts/test_swver.py +++ b/tests/unit/facts/test_swver.py @@ -7,12 +7,12 @@ import unittest2 as unittest except: import unittest -from nose.plugins.attrib import attr +import nose2 from jnpr.junos.facts.swver import version_info, get_facts -@attr("unit") + class TestVersionInfo(unittest.TestCase): if six.PY2: assertCountEqual = unittest.TestCase.assertItemsEqual diff --git a/tests/unit/ofacts/test_chassis.py b/tests/unit/ofacts/test_chassis.py index 5ca068f56..d52fe8e70 100644 --- a/tests/unit/ofacts/test_chassis.py +++ b/tests/unit/ofacts/test_chassis.py @@ -2,7 +2,7 @@ __credits__ = "Jeremy Schulman" import unittest -from nose.plugins.attrib import attr +import nose2 from mock import patch, MagicMock from lxml import etree import os @@ -16,7 +16,7 @@ from ncclient.transport import SSHSession -@attr("unit") + class TestChassis(unittest.TestCase): @patch("ncclient.manager.connect") @patch("jnpr.junos.device.warnings") diff --git a/tests/unit/ofacts/test_domain.py b/tests/unit/ofacts/test_domain.py index 1b6c7a50e..5a33bf6cc 100644 --- a/tests/unit/ofacts/test_domain.py +++ b/tests/unit/ofacts/test_domain.py @@ -2,7 +2,7 @@ __credits__ = "Jeremy Schulman" import unittest -from nose.plugins.attrib import attr +import nose2 from mock import patch, MagicMock from lxml import etree @@ -11,7 +11,7 @@ from jnpr.junos.exception import RpcError -@attr("unit") + class TestDomain(unittest.TestCase): @patch("ncclient.manager.connect") @patch("jnpr.junos.device.warnings") diff --git a/tests/unit/ofacts/test_ifd_style.py b/tests/unit/ofacts/test_ifd_style.py index 1e97e58d1..235649dd4 100644 --- a/tests/unit/ofacts/test_ifd_style.py +++ b/tests/unit/ofacts/test_ifd_style.py @@ -3,13 +3,13 @@ import unittest from mock import patch -from nose.plugins.attrib import attr +import nose2 from jnpr.junos import Device from jnpr.junos.ofacts.ifd_style import facts_ifd_style as ifd_style -@attr("unit") + class TestIFDStyle(unittest.TestCase): @patch("jnpr.junos.device.warnings") def setUp(self, mock_warnings): diff --git a/tests/unit/ofacts/test_personality.py b/tests/unit/ofacts/test_personality.py index 38cd84f36..a92e24d61 100644 --- a/tests/unit/ofacts/test_personality.py +++ b/tests/unit/ofacts/test_personality.py @@ -3,13 +3,13 @@ import unittest from mock import patch -from nose.plugins.attrib import attr +import nose2 from jnpr.junos import Device from jnpr.junos.ofacts.personality import facts_personality as personality -@attr("unit") + class TestPersonality(unittest.TestCase): @patch("jnpr.junos.device.warnings") def setUp(self, mock_warnings): diff --git a/tests/unit/ofacts/test_routing_engines.py b/tests/unit/ofacts/test_routing_engines.py index 4fbce8dcd..a9b6bb5e8 100644 --- a/tests/unit/ofacts/test_routing_engines.py +++ b/tests/unit/ofacts/test_routing_engines.py @@ -2,7 +2,7 @@ __credits__ = "Jeremy Schulman" import unittest -from nose.plugins.attrib import attr +import nose2 from mock import patch, MagicMock import os import sys @@ -14,7 +14,7 @@ from ncclient.transport import SSHSession -@attr("unit") + class TestRoutingEngines(unittest.TestCase): @patch("ncclient.manager.connect") @patch("jnpr.junos.device.warnings") diff --git a/tests/unit/ofacts/test_srx_cluster.py b/tests/unit/ofacts/test_srx_cluster.py index 7508a50cf..8497e1d5c 100644 --- a/tests/unit/ofacts/test_srx_cluster.py +++ b/tests/unit/ofacts/test_srx_cluster.py @@ -2,7 +2,7 @@ __credits__ = "Jeremy Schulman" import unittest -from nose.plugins.attrib import attr +import nose2 from mock import patch import os @@ -13,7 +13,7 @@ from ncclient.transport import SSHSession -@attr("unit") + class TestSrxCluster(unittest.TestCase): @patch("ncclient.manager.connect") @patch("jnpr.junos.device.warnings") diff --git a/tests/unit/ofacts/test_switch_style.py b/tests/unit/ofacts/test_switch_style.py index 3deef0520..2b6a06407 100644 --- a/tests/unit/ofacts/test_switch_style.py +++ b/tests/unit/ofacts/test_switch_style.py @@ -3,13 +3,13 @@ import unittest from mock import patch -from nose.plugins.attrib import attr +import nose2 from jnpr.junos import Device from jnpr.junos.ofacts.switch_style import facts_switch_style as switch_style -@attr("unit") + class TestSwitchStyle(unittest.TestCase): @patch("jnpr.junos.device.warnings") def setUp(self, mock_warnings): diff --git a/tests/unit/ofacts/test_swver.py b/tests/unit/ofacts/test_swver.py index ba306e59f..8a7a1c157 100644 --- a/tests/unit/ofacts/test_swver.py +++ b/tests/unit/ofacts/test_swver.py @@ -5,7 +5,7 @@ import unittest2 as unittest except ImportError: import unittest -from nose.plugins.attrib import attr +import nose2 from mock import patch, MagicMock import os @@ -17,7 +17,7 @@ from jnpr.junos.exception import RpcError -@attr("unit") + class TestSwver(unittest.TestCase): @patch("ncclient.manager.connect") @patch("jnpr.junos.device.warnings") diff --git a/tests/unit/test_decorators.py b/tests/unit/test_decorators.py index 5eb102666..4f045f318 100644 --- a/tests/unit/test_decorators.py +++ b/tests/unit/test_decorators.py @@ -2,7 +2,7 @@ import unittest2 as unittest except ImportError: import unittest -from nose.plugins.attrib import attr +import nose2 from lxml.etree import XML @@ -22,7 +22,7 @@ __author__ = "Rick Sherman" -@attr("unit") + class Test_Decorators(unittest.TestCase): @patch("ncclient.manager.connect") def setUp(self, mock_connect): diff --git a/tests/unit/test_device.py b/tests/unit/test_device.py index 2a3f9a0a2..87be241a8 100644 --- a/tests/unit/test_device.py +++ b/tests/unit/test_device.py @@ -2,7 +2,7 @@ import unittest2 as unittest except ImportError: import unittest -from nose.plugins.attrib import attr +import nose2 from mock import MagicMock, patch, mock_open, call import os from lxml import etree @@ -53,7 +53,7 @@ } -@attr("unit") + class Test_MyTemplateLoader(unittest.TestCase): def setUp(self): from jnpr.junos.device import _MyTemplateLoader @@ -78,7 +78,6 @@ def test_temp_load_get_source_filter_true(self, os_path_mock): self.template_loader.get_source(None, None) -@attr("unit") class TestDevice(unittest.TestCase): @patch("ncclient.manager.connect") def setUp(self, mock_connect): diff --git a/tests/unit/test_exception.py b/tests/unit/test_exception.py index 65ad7a164..26ba43f20 100644 --- a/tests/unit/test_exception.py +++ b/tests/unit/test_exception.py @@ -1,5 +1,5 @@ import unittest -from nose.plugins.attrib import attr +import nose2 from jnpr.junos.exception import ( RpcError, CommitError, @@ -81,7 +81,7 @@ }""" -@attr("unit") + class Test_RpcError(unittest.TestCase): def test_rpcerror_repr(self): rsp = etree.XML(rpc_xml) diff --git a/tests/unit/test_factcache.py b/tests/unit/test_factcache.py index 89270dbcc..fdb0b4556 100644 --- a/tests/unit/test_factcache.py +++ b/tests/unit/test_factcache.py @@ -2,7 +2,7 @@ import unittest2 as unittest except ImportError: import unittest -from nose.plugins.attrib import attr +import nose2 from mock import patch, MagicMock, call from jnpr.junos.exception import FactLoopError @@ -15,7 +15,7 @@ __credits__ = "Jeremy Schulman, Nitin Kumar" -@attr("unit") + class TestFactCache(unittest.TestCase): @patch("ncclient.manager.connect") def setUp(self, mock_connect): diff --git a/tests/unit/test_junos.py b/tests/unit/test_junos.py index 77c5d6ff9..52fed0121 100644 --- a/tests/unit/test_junos.py +++ b/tests/unit/test_junos.py @@ -3,17 +3,17 @@ import unittest import sys -from nose.plugins.attrib import attr +import nose2 from mock import patch __author__ = "Nitin Kumar" __credits__ = "Jeremy Schulman" -@attr("unit") + class TestJunosInit(unittest.TestCase): def test_warning(self): - with patch.object(sys.modules["sys"], "version_info", (2, 6, 3)) as mock_sys: + with patch.object(sys.modules["sys"], "version_info", (2, 6, 8)) as mock_sys: from jnpr import junos - self.assertEqual(mock_sys, (2, 6, 3)) + self.assertEqual(mock_sys, (2, 6, 8)) diff --git a/tests/unit/test_jxml.py b/tests/unit/test_jxml.py index 725bd7201..32450b864 100644 --- a/tests/unit/test_jxml.py +++ b/tests/unit/test_jxml.py @@ -1,7 +1,7 @@ import os import unittest from io import StringIO -from nose.plugins.attrib import attr +import nose2 from mock import patch from jnpr.junos.jxml import ( NAME, @@ -17,7 +17,7 @@ __credits__ = "Jeremy Schulman" -@attr("unit") + class Test_JXML(unittest.TestCase): def test_name(self): op = NAME("test") diff --git a/tests/unit/test_rpcmeta.py b/tests/unit/test_rpcmeta.py index 4aa2cd53f..2235acb45 100644 --- a/tests/unit/test_rpcmeta.py +++ b/tests/unit/test_rpcmeta.py @@ -1,7 +1,7 @@ import unittest import os import re -from nose.plugins.attrib import attr +import nose2 from jnpr.junos.device import Device from jnpr.junos.rpcmeta import _RpcMetaExec @@ -17,7 +17,7 @@ __credits__ = "Jeremy Schulman" -@attr("unit") + class Test_RpcMetaExec(unittest.TestCase): @patch("ncclient.manager.connect") def setUp(self, mock_connect): diff --git a/tests/unit/transport/test_serial.py b/tests/unit/transport/test_serial.py index 075d3a5fb..e6d22025c 100644 --- a/tests/unit/transport/test_serial.py +++ b/tests/unit/transport/test_serial.py @@ -2,7 +2,7 @@ import unittest2 as unittest except ImportError: import unittest -from nose.plugins.attrib import attr +import nose2 from mock import MagicMock, patch import sys import six @@ -15,7 +15,7 @@ builtin_string = "builtins" -@attr("unit") + class TestSerial(unittest.TestCase): @patch("jnpr.junos.transport.tty_serial.serial.Serial.open") @patch("jnpr.junos.transport.tty_serial.serial.Serial.write") @@ -77,7 +77,7 @@ def test_tty_serial_read_prompt(self): self.assertEqual(self.dev._tty.read_prompt()[0], None) -@attr("unit") + class TestSerialWin(unittest.TestCase): @patch("jnpr.junos.transport.tty_serial.serial.Serial.open") @patch("jnpr.junos.transport.tty_serial.serial.Serial.read") diff --git a/tests/unit/transport/test_tty.py b/tests/unit/transport/test_tty.py index 88129c071..7d432b4b9 100644 --- a/tests/unit/transport/test_tty.py +++ b/tests/unit/transport/test_tty.py @@ -5,14 +5,14 @@ except ImportError: import unittest -from nose.plugins.attrib import attr +import nose2 from mock import MagicMock, patch from jnpr.junos.transport.tty import Terminal from jnpr.junos import exception as EzErrors -@attr("unit") + class TestTTY(unittest.TestCase): def setUp(self): logging.getLogger("jnpr.junos.tty") diff --git a/tests/unit/transport/test_tty_netconf.py b/tests/unit/transport/test_tty_netconf.py index 8b8e1dd4f..87e482c30 100644 --- a/tests/unit/transport/test_tty_netconf.py +++ b/tests/unit/transport/test_tty_netconf.py @@ -2,7 +2,7 @@ import unittest2 as unittest except ImportError: import unittest -from nose.plugins.attrib import attr +import nose2 from mock import MagicMock, patch from jnpr.junos.transport.tty_netconf import tty_netconf import six @@ -12,7 +12,7 @@ from ncclient.operations import RPCError -@attr("unit") + class TestTTYNetconf(unittest.TestCase): def setUp(self): self.tty_net = tty_netconf(MagicMock()) diff --git a/tests/unit/transport/test_tty_ssh.py b/tests/unit/transport/test_tty_ssh.py index 09d9cc526..b5f466376 100644 --- a/tests/unit/transport/test_tty_ssh.py +++ b/tests/unit/transport/test_tty_ssh.py @@ -5,12 +5,12 @@ import unittest2 as unittest except ImportError: import unittest -from nose.plugins.attrib import attr +import nose2 from mock import MagicMock, patch from jnpr.junos.transport.tty_ssh import SSH -@attr("unit") + class TestTTYSSH(unittest.TestCase): @patch("jnpr.junos.transport.tty_ssh.paramiko") def setUp(self, mock_paramiko): diff --git a/tests/unit/transport/test_tty_telnet.py b/tests/unit/transport/test_tty_telnet.py index e34c34578..de5e9f596 100644 --- a/tests/unit/transport/test_tty_telnet.py +++ b/tests/unit/transport/test_tty_telnet.py @@ -4,13 +4,13 @@ import unittest2 as unittest except ImportError: import unittest -from nose.plugins.attrib import attr +import nose2 from mock import MagicMock, patch from jnpr.junos.transport.tty_telnet import Telnet import six -@attr("unit") + class TestTTYTelnet(unittest.TestCase): @patch("jnpr.junos.transport.tty_telnet.telnetlib.Telnet") def setUp(self, mpock_telnet): diff --git a/tests/unit/utils/test_config.py b/tests/unit/utils/test_config.py index 72a37edd6..f50bac986 100644 --- a/tests/unit/utils/test_config.py +++ b/tests/unit/utils/test_config.py @@ -1,6 +1,6 @@ import unittest import sys -from nose.plugins.attrib import attr +import nose2 from jnpr.junos import Device from jnpr.junos.utils.config import Config @@ -32,7 +32,7 @@ builtin_string = "builtins" -@attr("unit") + class TestConfig(unittest.TestCase): @patch("ncclient.manager.connect") def setUp(self, mock_connect): diff --git a/tests/unit/utils/test_fs.py b/tests/unit/utils/test_fs.py index 0cc8eefc0..cac0bc2b1 100644 --- a/tests/unit/utils/test_fs.py +++ b/tests/unit/utils/test_fs.py @@ -1,5 +1,5 @@ import unittest -from nose.plugins.attrib import attr +import nose2 import os from ncclient.manager import Manager, make_device_handler @@ -16,7 +16,7 @@ __credits__ = "Jeremy Schulman" -@attr("unit") + class TestFS(unittest.TestCase): @patch("ncclient.manager.connect") def setUp(self, mock_connect): diff --git a/tests/unit/utils/test_ftp.py b/tests/unit/utils/test_ftp.py index ab3807236..3d0373938 100644 --- a/tests/unit/utils/test_ftp.py +++ b/tests/unit/utils/test_ftp.py @@ -1,5 +1,5 @@ import unittest -from nose.plugins.attrib import attr +import nose2 import ftplib import sys import os @@ -15,7 +15,7 @@ builtin_string = "builtins" -@attr("unit") + @unittest.skipIf(sys.platform == "win32", "will work for windows in coming days") class TestFtp(unittest.TestCase): @patch("ftplib.FTP.connect") diff --git a/tests/unit/utils/test_scp.py b/tests/unit/utils/test_scp.py index 66489e311..58f3472e1 100644 --- a/tests/unit/utils/test_scp.py +++ b/tests/unit/utils/test_scp.py @@ -3,7 +3,7 @@ from contextlib import contextmanager import unittest -from nose.plugins.attrib import attr +import nose2 from jnpr.junos import Device from jnpr.junos.utils.scp import SCP @@ -19,7 +19,7 @@ builtin_string = "builtins" -@attr("unit") + class TestScp(unittest.TestCase): def setUp(self): self.dev = Device(host="1.1.1.1") diff --git a/tests/unit/utils/test_start_shell.py b/tests/unit/utils/test_start_shell.py index 49642b357..a052a813a 100644 --- a/tests/unit/utils/test_start_shell.py +++ b/tests/unit/utils/test_start_shell.py @@ -1,5 +1,5 @@ import unittest -from nose.plugins.attrib import attr +import nose2 from jnpr.junos import Device from jnpr.junos.utils.start_shell import StartShell @@ -10,7 +10,7 @@ __credits__ = "Jeremy Schulman, Nitin Kumar" -@attr("unit") + class TestStartShell(unittest.TestCase): @patch("paramiko.SSHClient") def setUp(self, mock_connect): diff --git a/tests/unit/utils/test_sw.py b/tests/unit/utils/test_sw.py index 113cd02e6..794fb5fc0 100644 --- a/tests/unit/utils/test_sw.py +++ b/tests/unit/utils/test_sw.py @@ -7,7 +7,7 @@ import unittest2 as unittest except ImportError: import unittest -from nose.plugins.attrib import attr +import nose2 from contextlib import contextmanager from jnpr.junos import Device from jnpr.junos.exception import RpcError, SwRollbackError, RpcTimeoutError @@ -59,7 +59,7 @@ } -@attr("unit") + class TestSW(unittest.TestCase): @patch("ncclient.manager.connect") def setUp(self, mock_connect): diff --git a/tests/unit/utils/test_util.py b/tests/unit/utils/test_util.py index 8e6a267ab..11ec9816e 100644 --- a/tests/unit/utils/test_util.py +++ b/tests/unit/utils/test_util.py @@ -2,7 +2,7 @@ __credits__ = "Jeremy Schulman" import unittest -from nose.plugins.attrib import attr +import nose2 from jnpr.junos import Device from jnpr.junos.utils.util import Util @@ -10,7 +10,7 @@ from mock import patch -@attr("unit") + class TestUtil(unittest.TestCase): @patch("ncclient.manager.connect") def setUp(self, mock_connect): From 62a8d1de75722ca7bb97a5cf8377cd9bc553d8b4 Mon Sep 17 00:00:00 2001 From: chidanandpujar Date: Fri, 17 Nov 2023 22:16:08 +0530 Subject: [PATCH 04/28] python3.12 support --- .github/workflows/pylint.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index 9c226a1c4..17df7f35b 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -14,7 +14,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest] - python-version: [3.7, 3.8, 3.9] + python-version: [3.7, 3.8, 3.9, 3.10, 3.12] exclude: - os: windows-latest python-version: 3.8 @@ -44,4 +44,7 @@ jobs: - name: Run unit tests run: | + pip install nose2 + pip install nose2[coverage_plugin] nosetests -v --with-coverage --cover-package=jnpr.junos --cover-inclusive -a unit + nose2 -v --coverage jnpr.junos --with-coverage From 7dc2c7b1e6d2db04f523c0683924a5feb724c59d Mon Sep 17 00:00:00 2001 From: chidanandpujar Date: Fri, 17 Nov 2023 22:18:25 +0530 Subject: [PATCH 05/28] python3.12 support --- .github/workflows/pylint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index 17df7f35b..8560c2ba0 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -14,7 +14,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest] - python-version: [3.7, 3.8, 3.9, 3.10, 3.12] + python-version: [3.7, 3.8, 3.9, 3.12] exclude: - os: windows-latest python-version: 3.8 From e0bfb3a62f16593eb0ae6fd59bd5f55e388156fa Mon Sep 17 00:00:00 2001 From: chidanandpujar Date: Fri, 17 Nov 2023 22:21:01 +0530 Subject: [PATCH 06/28] python3.12 support --- tests/unit/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py index 7329bda2b..0343c0bcd 100644 --- a/tests/unit/__init__.py +++ b/tests/unit/__init__.py @@ -8,7 +8,7 @@ __credits__ = "Jeremy Schulman" -@attr("unit") + class TestJunosInit(unittest.TestCase): def test_warning(self): with patch.object(sys.modules["sys"], "version_info", (2, 6, 8)) as mock_sys: From d1d8bc8e7e485106b2c82ad685c65703887e30ce Mon Sep 17 00:00:00 2001 From: chidanandpujar Date: Fri, 17 Nov 2023 22:26:54 +0530 Subject: [PATCH 07/28] python3.12 support --- .github/workflows/pylint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index 8560c2ba0..95c1c294d 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -47,4 +47,4 @@ jobs: pip install nose2 pip install nose2[coverage_plugin] nosetests -v --with-coverage --cover-package=jnpr.junos --cover-inclusive -a unit - nose2 -v --coverage jnpr.junos --with-coverage + nose2 -v --coverage jnpr.junos --with-coverage unit From 8d76145644f666d0518e9276bd6b88dedca47fb9 Mon Sep 17 00:00:00 2001 From: chidanandpujar Date: Fri, 17 Nov 2023 22:36:21 +0530 Subject: [PATCH 08/28] python3.12 support --- .github/workflows/pylint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index 95c1c294d..269e38e7b 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -47,4 +47,4 @@ jobs: pip install nose2 pip install nose2[coverage_plugin] nosetests -v --with-coverage --cover-package=jnpr.junos --cover-inclusive -a unit - nose2 -v --coverage jnpr.junos --with-coverage unit + nose2 -v --coverage jnpr.junos --with-coverage tests.unit From aad20f82a7b29cb1f5d3d62e2e03a348d5eab359 Mon Sep 17 00:00:00 2001 From: chidanandpujar Date: Mon, 20 Nov 2023 10:44:08 +0530 Subject: [PATCH 09/28] python3.12 support --- .github/workflows/pylint.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index 269e38e7b..96d632d2f 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -46,5 +46,4 @@ jobs: run: | pip install nose2 pip install nose2[coverage_plugin] - nosetests -v --with-coverage --cover-package=jnpr.junos --cover-inclusive -a unit nose2 -v --coverage jnpr.junos --with-coverage tests.unit From 8deb3d05bfc3e0fd177c8a8bf2a837591ab559b1 Mon Sep 17 00:00:00 2001 From: chidanandpujar Date: Wed, 29 Nov 2023 10:43:11 +0530 Subject: [PATCH 10/28] python3.12 support --- .github/workflows/pylint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index 96d632d2f..bb9c7994f 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -14,7 +14,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest] - python-version: [3.7, 3.8, 3.9, 3.12] + python-version: [3.9, '3.10',3.12] exclude: - os: windows-latest python-version: 3.8 From cf682e3c1042d91c81712c0ab6bd99ef3894dcdf Mon Sep 17 00:00:00 2001 From: chidanandpujar Date: Wed, 29 Nov 2023 10:45:15 +0530 Subject: [PATCH 11/28] python3.12 support --- .github/workflows/pylint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index bb9c7994f..b0321fca4 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -14,7 +14,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest] - python-version: [3.9, '3.10',3.12] + python-version: [3.9, '3.10', 3.11, 3.12] exclude: - os: windows-latest python-version: 3.8 From 945f44bad663f83b1c97e59e859d966a0df52fe5 Mon Sep 17 00:00:00 2001 From: chidanandpujar Date: Wed, 29 Nov 2023 11:05:05 +0530 Subject: [PATCH 12/28] python3.12 support --- .github/workflows/pylint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index b0321fca4..94fd0eac6 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -14,7 +14,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest] - python-version: [3.9, '3.10', 3.11, 3.12] + python-version: [3.9.6, '3.10', 3.11, 3.12] exclude: - os: windows-latest python-version: 3.8 From 5373d704ab17a76f2443bd9b3e00a329005bfb13 Mon Sep 17 00:00:00 2001 From: chidanandpujar Date: Wed, 29 Nov 2023 11:06:30 +0530 Subject: [PATCH 13/28] python3.12 support --- .github/workflows/pylint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index 94fd0eac6..b0321fca4 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -14,7 +14,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest] - python-version: [3.9.6, '3.10', 3.11, 3.12] + python-version: [3.9, '3.10', 3.11, 3.12] exclude: - os: windows-latest python-version: 3.8 From 9dae983ba10f631137b150e787356edc0a4636f5 Mon Sep 17 00:00:00 2001 From: chidanandpujar Date: Wed, 29 Nov 2023 11:51:54 +0530 Subject: [PATCH 14/28] python3.12 support --- lib/jnpr/junos/utils/start_shell.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jnpr/junos/utils/start_shell.py b/lib/jnpr/junos/utils/start_shell.py index f78e93e06..8fc4e5e49 100644 --- a/lib/jnpr/junos/utils/start_shell.py +++ b/lib/jnpr/junos/utils/start_shell.py @@ -84,7 +84,7 @@ def wait_for(self, this=_SHELL_PROMPT, timeout=0, sleep=0): if isinstance(data, bytes): data = data.decode("utf-8", "replace") got.append(data) - if this is not None and re.search(r"{}\s?$".format(this), data): + if this is not None and re.search(r"{}\s?$".format(this), str(data)): break return got From 43dc2095e86fdbca2961bca69e78854c0d0d7670 Mon Sep 17 00:00:00 2001 From: chidanandpujar Date: Wed, 29 Nov 2023 12:03:36 +0530 Subject: [PATCH 15/28] python3.12 support --- tests/unit/utils/test_start_shell.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/utils/test_start_shell.py b/tests/unit/utils/test_start_shell.py index a052a813a..eaa8ea778 100644 --- a/tests/unit/utils/test_start_shell.py +++ b/tests/unit/utils/test_start_shell.py @@ -70,7 +70,7 @@ def test_startshell_wait_for_regex(self, mock_select): ---(more)--- """ self.assertTrue( - self.shell.wait_for("---\(more\s?\d*%?\)---\n\s*|%")[0] + str(self.shell.wait_for("---\(more\s?\d*%?\)---\n\s*|%")[0]) in self.shell._chan.recv.return_value ) From 0e39c64233cd642a3e910e1625f839a4f955e7ff Mon Sep 17 00:00:00 2001 From: chidanandpujar Date: Wed, 29 Nov 2023 12:15:48 +0530 Subject: [PATCH 16/28] python3.12 support --- lib/jnpr/junos/utils/start_shell.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jnpr/junos/utils/start_shell.py b/lib/jnpr/junos/utils/start_shell.py index 8fc4e5e49..f78e93e06 100644 --- a/lib/jnpr/junos/utils/start_shell.py +++ b/lib/jnpr/junos/utils/start_shell.py @@ -84,7 +84,7 @@ def wait_for(self, this=_SHELL_PROMPT, timeout=0, sleep=0): if isinstance(data, bytes): data = data.decode("utf-8", "replace") got.append(data) - if this is not None and re.search(r"{}\s?$".format(this), str(data)): + if this is not None and re.search(r"{}\s?$".format(this), data): break return got From c43b48cdda4d6446c19003423d6529052733b9eb Mon Sep 17 00:00:00 2001 From: chidanandpujar Date: Wed, 29 Nov 2023 13:13:50 +0530 Subject: [PATCH 17/28] python3.12 support --- .github/workflows/pylint.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index b0321fca4..57e976c79 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -35,6 +35,7 @@ jobs: pip install -r development.txt pip install ntc_templates==1.4.1 pip install textfsm==0.4.1 + pip install nose2 pip install . - name: Run black tool @@ -44,6 +45,4 @@ jobs: - name: Run unit tests run: | - pip install nose2 - pip install nose2[coverage_plugin] nose2 -v --coverage jnpr.junos --with-coverage tests.unit From 7669f68694457abcb49638e92d9251cbd9381481 Mon Sep 17 00:00:00 2001 From: chidanandpujar Date: Wed, 29 Nov 2023 13:16:24 +0530 Subject: [PATCH 18/28] python3.12 support --- .github/workflows/pylint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index 57e976c79..b8ca5dc85 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -45,4 +45,4 @@ jobs: - name: Run unit tests run: | - nose2 -v --coverage jnpr.junos --with-coverage tests.unit + nose2 -vvv tests.unit From ae404483afd9c5a02eec75a018a052e81f3d2b6d Mon Sep 17 00:00:00 2001 From: chidanandpujar Date: Wed, 29 Nov 2023 13:44:34 +0530 Subject: [PATCH 19/28] python3.12 support --- lib/jnpr/junos/utils/start_shell.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/jnpr/junos/utils/start_shell.py b/lib/jnpr/junos/utils/start_shell.py index f78e93e06..795384a00 100644 --- a/lib/jnpr/junos/utils/start_shell.py +++ b/lib/jnpr/junos/utils/start_shell.py @@ -119,7 +119,6 @@ def open(self): stdin=subprocess.PIPE, stdout=subprocess.PIPE, close_fds=1, - bufsize=1, ) else: self._client = open_ssh_client(dev=self._nc) From c12a0fcff1d6852b8ce73a3c60c1a97df01f28a1 Mon Sep 17 00:00:00 2001 From: chidanandpujar Date: Wed, 29 Nov 2023 15:12:08 +0530 Subject: [PATCH 20/28] python3.12 support --- lib/jnpr/junos/utils/start_shell.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/jnpr/junos/utils/start_shell.py b/lib/jnpr/junos/utils/start_shell.py index 795384a00..57034a346 100644 --- a/lib/jnpr/junos/utils/start_shell.py +++ b/lib/jnpr/junos/utils/start_shell.py @@ -119,6 +119,7 @@ def open(self): stdin=subprocess.PIPE, stdout=subprocess.PIPE, close_fds=1, + bufsize=0, ) else: self._client = open_ssh_client(dev=self._nc) From 3bdc5b515e6161f0628145fc51fd389349c1059f Mon Sep 17 00:00:00 2001 From: chidanandpujar Date: Wed, 29 Nov 2023 15:37:34 +0530 Subject: [PATCH 21/28] python3.12 support --- .github/workflows/pylint.yml | 1 + lib/jnpr/junos/utils/start_shell.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index b8ca5dc85..97ba6f533 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -45,4 +45,5 @@ jobs: - name: Run unit tests run: | + echo $SHELL nose2 -vvv tests.unit diff --git a/lib/jnpr/junos/utils/start_shell.py b/lib/jnpr/junos/utils/start_shell.py index 57034a346..520de8ee6 100644 --- a/lib/jnpr/junos/utils/start_shell.py +++ b/lib/jnpr/junos/utils/start_shell.py @@ -113,6 +113,7 @@ def open(self): :class:`paramiko.SSHClient` instance. """ if self.ON_JUNOS is True: + print("Debug1", self.ON_JUNOS) self._chan = subprocess.Popen( ["cli", "start", "shell", self.shell_type], shell=False, @@ -122,6 +123,7 @@ def open(self): bufsize=0, ) else: + print("Debug2", self.ON_JUNOS) self._client = open_ssh_client(dev=self._nc) self._chan = self._client.invoke_shell() From 0bebe8647d7e2b7fbd2a879643f3192af5a53c04 Mon Sep 17 00:00:00 2001 From: chidanandpujar Date: Wed, 29 Nov 2023 15:50:07 +0530 Subject: [PATCH 22/28] python3.12 support --- lib/jnpr/junos/utils/start_shell.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/jnpr/junos/utils/start_shell.py b/lib/jnpr/junos/utils/start_shell.py index 520de8ee6..8761b8540 100644 --- a/lib/jnpr/junos/utils/start_shell.py +++ b/lib/jnpr/junos/utils/start_shell.py @@ -112,6 +112,7 @@ def open(self): drop into the Junos shell (csh). This process opens a :class:`paramiko.SSHClient` instance. """ + print("Debug1", self.ON_JUNOS) if self.ON_JUNOS is True: print("Debug1", self.ON_JUNOS) self._chan = subprocess.Popen( From e9b183b00257dcbf2866864fb0f085608a136eb2 Mon Sep 17 00:00:00 2001 From: chidanandpujar Date: Wed, 29 Nov 2023 15:55:03 +0530 Subject: [PATCH 23/28] python3.12 support --- lib/jnpr/junos/utils/start_shell.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/jnpr/junos/utils/start_shell.py b/lib/jnpr/junos/utils/start_shell.py index 8761b8540..260a364eb 100644 --- a/lib/jnpr/junos/utils/start_shell.py +++ b/lib/jnpr/junos/utils/start_shell.py @@ -71,6 +71,7 @@ def wait_for(self, this=_SHELL_PROMPT, timeout=0, sleep=0): timeout = timeout or self.timeout timeout = datetime.datetime.now() + datetime.timedelta(seconds=timeout) while timeout > datetime.datetime.now(): + print("Debug2 wait_for", self.ON_JUNOS) if self.ON_JUNOS is True: data = chan.stdout.readline() else: @@ -112,7 +113,7 @@ def open(self): drop into the Junos shell (csh). This process opens a :class:`paramiko.SSHClient` instance. """ - print("Debug1", self.ON_JUNOS) + print("Debug1 open", self.ON_JUNOS) if self.ON_JUNOS is True: print("Debug1", self.ON_JUNOS) self._chan = subprocess.Popen( @@ -124,7 +125,7 @@ def open(self): bufsize=0, ) else: - print("Debug2", self.ON_JUNOS) + print("Debug2 open", self.ON_JUNOS) self._client = open_ssh_client(dev=self._nc) self._chan = self._client.invoke_shell() From 0e0614f5c2fc9f9d612dfdd8d6f0e580b9a5834e Mon Sep 17 00:00:00 2001 From: chidanandpujar Date: Wed, 29 Nov 2023 16:11:12 +0530 Subject: [PATCH 24/28] python3.12 support --- .github/workflows/pylint.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index 97ba6f533..445cf6665 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -46,4 +46,5 @@ jobs: - name: Run unit tests run: | echo $SHELL + uname -a nose2 -vvv tests.unit From a8e2dffa8a3a96f593d1d47c61ea5a0528e482e1 Mon Sep 17 00:00:00 2001 From: chidanandpujar Date: Wed, 29 Nov 2023 16:13:57 +0530 Subject: [PATCH 25/28] python3.12 support --- .github/workflows/pylint.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index 445cf6665..f3ee1c380 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -47,4 +47,5 @@ jobs: run: | echo $SHELL uname -a + lsb_release -a nose2 -vvv tests.unit From 5014e06c97cba2f05a44faded4e05c958a3d7fe2 Mon Sep 17 00:00:00 2001 From: chidanandpujar Date: Wed, 29 Nov 2023 16:22:33 +0530 Subject: [PATCH 26/28] python3.12 support --- lib/jnpr/junos/utils/start_shell.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/jnpr/junos/utils/start_shell.py b/lib/jnpr/junos/utils/start_shell.py index 260a364eb..7d9fe9209 100644 --- a/lib/jnpr/junos/utils/start_shell.py +++ b/lib/jnpr/junos/utils/start_shell.py @@ -71,7 +71,6 @@ def wait_for(self, this=_SHELL_PROMPT, timeout=0, sleep=0): timeout = timeout or self.timeout timeout = datetime.datetime.now() + datetime.timedelta(seconds=timeout) while timeout > datetime.datetime.now(): - print("Debug2 wait_for", self.ON_JUNOS) if self.ON_JUNOS is True: data = chan.stdout.readline() else: @@ -113,9 +112,8 @@ def open(self): drop into the Junos shell (csh). This process opens a :class:`paramiko.SSHClient` instance. """ - print("Debug1 open", self.ON_JUNOS) if self.ON_JUNOS is True: - print("Debug1", self.ON_JUNOS) + print("Debug1 open", self.ON_JUNOS) self._chan = subprocess.Popen( ["cli", "start", "shell", self.shell_type], shell=False, @@ -125,7 +123,6 @@ def open(self): bufsize=0, ) else: - print("Debug2 open", self.ON_JUNOS) self._client = open_ssh_client(dev=self._nc) self._chan = self._client.invoke_shell() From 4d5b90095f2744226135bd3607cd3f67ce238205 Mon Sep 17 00:00:00 2001 From: chidanandpujar Date: Wed, 29 Nov 2023 16:37:34 +0530 Subject: [PATCH 27/28] python3.12 support --- .github/workflows/pylint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index f3ee1c380..ef41e57f3 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -13,7 +13,7 @@ jobs: strategy: matrix: - os: [ubuntu-latest, windows-latest] + os: [ubuntu-20.04, windows-latest] python-version: [3.9, '3.10', 3.11, 3.12] exclude: - os: windows-latest From 1420c9eb42f8a0965b8527df1e702ca387986711 Mon Sep 17 00:00:00 2001 From: chidanandpujar Date: Wed, 29 Nov 2023 16:46:38 +0530 Subject: [PATCH 28/28] python3.12 support --- lib/jnpr/junos/utils/start_shell.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/jnpr/junos/utils/start_shell.py b/lib/jnpr/junos/utils/start_shell.py index 7d9fe9209..57034a346 100644 --- a/lib/jnpr/junos/utils/start_shell.py +++ b/lib/jnpr/junos/utils/start_shell.py @@ -113,7 +113,6 @@ def open(self): :class:`paramiko.SSHClient` instance. """ if self.ON_JUNOS is True: - print("Debug1 open", self.ON_JUNOS) self._chan = subprocess.Popen( ["cli", "start", "shell", self.shell_type], shell=False,