Skip to content

Commit

Permalink
JP-0 | feat: support for pythjon3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksandr Novichkov committed Dec 28, 2023
1 parent 4ea83de commit 8523f61
Show file tree
Hide file tree
Showing 55 changed files with 261 additions and 295 deletions.
203 changes: 105 additions & 98 deletions docs/conf.py

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions tests/functional/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from jnpr.junos.exception import RpcTimeoutError


class TestCore(unittest.TestCase):
@classmethod
def setUpClass(self):
Expand Down
1 change: 1 addition & 0 deletions tests/functional/test_outbound_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import socket
from jnpr.junos import Device


class TestDeviceSsh(unittest.TestCase):
def tearDown(self):
self.dev.close()
Expand Down
15 changes: 10 additions & 5 deletions tests/functional/test_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@

import yaml

class test(unittest.TestCase):

class test(unittest.TestCase):
@classmethod
def setUpClass(self):
from jnpr.junos import Device

with open("config.yaml", "r") as fyaml:
cfg = yaml.safe_load(fyaml)
self.dev = Device(**cfg)
Expand All @@ -23,24 +24,28 @@ def tearDownClass(self):

def test_shell_run(self):
from jnpr.junos.utils.start_shell import StartShell

with StartShell(self.dev) as sh:
output = sh.run('pwd')
output = sh.run("pwd")
self.assertTrue(output[0])

def test_shell_run_with_sleep(self):
from jnpr.junos.utils.start_shell import StartShell

with StartShell(self.dev) as sh:
output = sh.run('hostname', sleep=2)
output = sh.run("hostname", sleep=2)
self.assertTrue(output[0])

def test_shell_run_shell_type_ssh(self):
from jnpr.junos.utils.start_shell import StartShell

with StartShell(self.dev, shell_type="ssh") as sh:
output = sh.run('hostname', sleep=2)
output = sh.run("hostname", sleep=2)
self.assertTrue(output[0])

def test_shell_run_shell_type_csh(self):
from jnpr.junos.utils.start_shell import StartShell

with StartShell(self.dev, shell_type="csh") as sh:
output = sh.run('hostname', sleep=2)
output = sh.run("hostname", sleep=2)
self.assertTrue(output[0])
1 change: 0 additions & 1 deletion tests/unit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
__credits__ = "Jeremy Schulman"



class TestJunosInit(unittest.TestCase):
def test_warning(self):
with patch.object(sys.modules["sys"], "version_info", (3, 8, 0)) as mock_sys:
Expand Down
1 change: 0 additions & 1 deletion tests/unit/factory/test_cfgtable.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@
globals().update(FactoryLoader().load(yaml.load(yaml_bgp_data, Loader=yaml.FullLoader)))



@unittest.skipIf(sys.platform == "win32", "will work for windows in coming days")
class TestFactoryCfgTable(unittest.TestCase):
@patch("ncclient.manager.connect")
Expand Down
253 changes: 126 additions & 127 deletions tests/unit/factory/test_cmdtable.py

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion tests/unit/factory/test_factory_cls.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from jnpr.junos.factory.factory_cls import FactoryTable, FactoryView



class TestFactoryCls(unittest.TestCase):
def test_factory_cls_cfgtable(self):
t = FactoryCfgTable()
Expand Down
1 change: 0 additions & 1 deletion tests/unit/factory/test_factory_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from mock import patch



class TestFactoryLoader(unittest.TestCase):
def setUp(self):
self.fl = FactoryLoader()
Expand Down
1 change: 0 additions & 1 deletion tests/unit/factory/test_optable.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
from mock import patch



class TestFactoryOpTable(unittest.TestCase):
@patch("ncclient.manager.connect")
def setUp(self, mock_connect):
Expand Down
1 change: 0 additions & 1 deletion tests/unit/factory/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
builtin_string = "builtins"



class TestFactoryTable(unittest.TestCase):
@patch("ncclient.manager.connect")
def setUp(self, mock_connect):
Expand Down
1 change: 0 additions & 1 deletion tests/unit/factory/test_to_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from ncclient.operations.rpc import RPCReply



class TestToJson(unittest.TestCase):
@patch("ncclient.manager.connect")
def setUp(self, mock_connect):
Expand Down
1 change: 0 additions & 1 deletion tests/unit/factory/test_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from lxml import etree



class TestFactoryView(unittest.TestCase):
def setUp(self):
self.dev = Device(
Expand Down
1 change: 0 additions & 1 deletion tests/unit/factory/test_view_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from jnpr.junos.factory.viewfields import ViewFields



class TestFactoryViewFields(unittest.TestCase):
def setUp(self):
self.vf = ViewFields()
Expand Down
1 change: 0 additions & 1 deletion tests/unit/facts/test__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import jnpr.junos.facts



class TestFactInitialization(unittest.TestCase):
def test_duplicate_facts(self):
module = importlib.import_module("tests.unit.facts.dupe_foo1")
Expand Down
1 change: 0 additions & 1 deletion tests/unit/facts/test_current_re.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from ncclient.transport import SSHSession



class TestCurrentRe(unittest.TestCase):
@patch("ncclient.manager.connect")
def setUp(self, mock_connect):
Expand Down
1 change: 0 additions & 1 deletion tests/unit/facts/test_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from ncclient.transport import SSHSession



class TestDomain(unittest.TestCase):
@patch("ncclient.manager.connect")
def setUp(self, mock_connect):
Expand Down
1 change: 0 additions & 1 deletion tests/unit/facts/test_ethernet_mac_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from ncclient.transport import SSHSession



class TestEthernetMacTable(unittest.TestCase):
@patch("ncclient.manager.connect")
def setUp(self, mock_connect):
Expand Down
1 change: 0 additions & 1 deletion tests/unit/facts/test_file_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from ncclient.transport import SSHSession



class TestFileList(unittest.TestCase):
@patch("ncclient.manager.connect")
def setUp(self, mock_connect):
Expand Down
1 change: 0 additions & 1 deletion tests/unit/facts/test_get_chassis_cluster_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from ncclient.transport import SSHSession



class TestGetChassisClusterStatus(unittest.TestCase):
@patch("ncclient.manager.connect")
def setUp(self, mock_connect):
Expand Down
1 change: 0 additions & 1 deletion tests/unit/facts/test_get_chassis_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from ncclient.transport import SSHSession



class TestChassis(unittest.TestCase):
@patch("ncclient.manager.connect")
def setUp(self, mock_connect):
Expand Down
1 change: 0 additions & 1 deletion tests/unit/facts/test_get_route_engine_information.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from ncclient.transport import SSHSession



class TestGetRouteEngineInformation(unittest.TestCase):
@patch("ncclient.manager.connect")
def setUp(self, mock_connect):
Expand Down
1 change: 0 additions & 1 deletion tests/unit/facts/test_get_software_information.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from ncclient.transport import SSHSession



class TestGetSoftwareInformation(unittest.TestCase):
@patch("ncclient.manager.connect")
def setUp(self, mock_connect):
Expand Down
1 change: 0 additions & 1 deletion tests/unit/facts/test_get_virtual_chassis_information.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from ncclient.transport import SSHSession



class TestGetVirtualChassisInformation(unittest.TestCase):
@patch("ncclient.manager.connect")
def setUp(self, mock_connect):
Expand Down
1 change: 0 additions & 1 deletion tests/unit/facts/test_ifd_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from ncclient.transport import SSHSession



class TestIfdStyle(unittest.TestCase):
@patch("ncclient.manager.connect")
def setUp(self, mock_connect):
Expand Down
1 change: 0 additions & 1 deletion tests/unit/facts/test_iri_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from ncclient.transport import SSHSession



class TestIriMapping(unittest.TestCase):
@patch("ncclient.manager.connect")
def setUp(self, mock_connect):
Expand Down
1 change: 0 additions & 1 deletion tests/unit/facts/test_personality.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from ncclient.transport import SSHSession



class TestPersonality(unittest.TestCase):
@patch("ncclient.manager.connect")
def setUp(self, mock_connect):
Expand Down
1 change: 0 additions & 1 deletion tests/unit/facts/test_swver.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from jnpr.junos.facts.swver import version_info, get_facts



class TestVersionInfo(unittest.TestCase):
if six.PY2:
assertCountEqual = unittest.TestCase.assertItemsEqual
Expand Down
1 change: 0 additions & 1 deletion tests/unit/ofacts/test_chassis.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from ncclient.transport import SSHSession



class TestChassis(unittest.TestCase):
@patch("ncclient.manager.connect")
@patch("jnpr.junos.device.warnings")
Expand Down
1 change: 0 additions & 1 deletion tests/unit/ofacts/test_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from jnpr.junos.exception import RpcError



class TestDomain(unittest.TestCase):
@patch("ncclient.manager.connect")
@patch("jnpr.junos.device.warnings")
Expand Down
1 change: 0 additions & 1 deletion tests/unit/ofacts/test_ifd_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from jnpr.junos.ofacts.ifd_style import facts_ifd_style as ifd_style



class TestIFDStyle(unittest.TestCase):
@patch("jnpr.junos.device.warnings")
def setUp(self, mock_warnings):
Expand Down
1 change: 0 additions & 1 deletion tests/unit/ofacts/test_personality.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from jnpr.junos.ofacts.personality import facts_personality as personality



class TestPersonality(unittest.TestCase):
@patch("jnpr.junos.device.warnings")
def setUp(self, mock_warnings):
Expand Down
1 change: 0 additions & 1 deletion tests/unit/ofacts/test_routing_engines.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from ncclient.transport import SSHSession



class TestRoutingEngines(unittest.TestCase):
@patch("ncclient.manager.connect")
@patch("jnpr.junos.device.warnings")
Expand Down
1 change: 0 additions & 1 deletion tests/unit/ofacts/test_srx_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from ncclient.transport import SSHSession



class TestSrxCluster(unittest.TestCase):
@patch("ncclient.manager.connect")
@patch("jnpr.junos.device.warnings")
Expand Down
1 change: 0 additions & 1 deletion tests/unit/ofacts/test_switch_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from jnpr.junos.ofacts.switch_style import facts_switch_style as switch_style



class TestSwitchStyle(unittest.TestCase):
@patch("jnpr.junos.device.warnings")
def setUp(self, mock_warnings):
Expand Down
1 change: 0 additions & 1 deletion tests/unit/ofacts/test_swver.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from jnpr.junos.exception import RpcError



class TestSwver(unittest.TestCase):
@patch("ncclient.manager.connect")
@patch("jnpr.junos.device.warnings")
Expand Down
1 change: 0 additions & 1 deletion tests/unit/test_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
__author__ = "Rick Sherman"



class Test_Decorators(unittest.TestCase):
@patch("ncclient.manager.connect")
def setUp(self, mock_connect):
Expand Down
9 changes: 6 additions & 3 deletions tests/unit/test_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
}



class Test_MyTemplateLoader(unittest.TestCase):
def setUp(self):
from jnpr.junos.device import _MyTemplateLoader
Expand Down Expand Up @@ -475,7 +474,9 @@ def test_device_open_with_look_for_keys_False(self, mock_connect, mock_execute):
"""
mock_connect.side_effect = self._mock_manager
mock_execute.side_effect = self._mock_manager
self.dev2 = Device(host="2.2.2.2", user="test", password="password123", look_for_keys=False)
self.dev2 = Device(
host="2.2.2.2", user="test", password="password123", look_for_keys=False
)
self.dev2.open()
self.assertEqual(self.dev2.connected, True)

Expand All @@ -490,7 +491,9 @@ def test_device_open_with_look_for_keys_True(self, mock_connect, mock_execute):
"""
mock_connect.side_effect = self._mock_manager
mock_execute.side_effect = self._mock_manager
self.dev2 = Device(host="2.2.2.2", user="test", password="password123", look_for_keys=True)
self.dev2 = Device(
host="2.2.2.2", user="test", password="password123", look_for_keys=True
)
self.dev2.open()
self.assertEqual(self.dev2.connected, True)

Expand Down
1 change: 0 additions & 1 deletion tests/unit/test_exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@
}"""



class Test_RpcError(unittest.TestCase):
def test_rpcerror_repr(self):
rsp = etree.XML(rpc_xml)
Expand Down
1 change: 0 additions & 1 deletion tests/unit/test_factcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
__credits__ = "Jeremy Schulman, Nitin Kumar"



class TestFactCache(unittest.TestCase):
@patch("ncclient.manager.connect")
def setUp(self, mock_connect):
Expand Down
1 change: 0 additions & 1 deletion tests/unit/test_junos.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
__credits__ = "Jeremy Schulman"



class TestJunosInit(unittest.TestCase):
def test_warning(self):
print(sys.modules["sys"].version_info)
Expand Down
Loading

0 comments on commit 8523f61

Please sign in to comment.