Skip to content

Commit

Permalink
Revert "Fix Python 3.12: SyntaxWarning: invalid escape sequence '\s' (
Browse files Browse the repository at this point in the history
closes #1312)"
  • Loading branch information
dineshbaburam91 authored Oct 8, 2024
1 parent 02c7d02 commit 3dbe7d9
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion lib/jnpr/junos/transport/tty.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Terminal(object):
"(?P<badpasswd>ogin incorrect)",
r"(?P<netconf_closed><!-- session end at .*-->\s*)",
r"(?P<shell>%|#|(~\$)\s*$)",
r'(?P<cli>[^\-"]>\s*$)',
'(?P<cli>[^\\-"]>\s*$)',
r"(?P<option>Enter your option:\s*$)",
"(?P<hotkey>connection: <CTRL>Z)",
]
Expand Down
26 changes: 13 additions & 13 deletions tests/unit/factory/test_cmdtable.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ def test_cmdtable_iter(self, mock_execute):
@patch("jnpr.junos.Device.execute")
def test_title_in_view(self, mock_execute):
mock_execute.side_effect = self._mock_manager
yaml_data = r"""
yaml_data = """
---
ShowLuchipTable:
command: show luchip {{ lu_instance }}
Expand Down Expand Up @@ -498,7 +498,7 @@ def test_unstructured_linkstats(self, mock_execute):
@patch("jnpr.junos.Device.execute")
def test_field_eval(self, mock_execute):
mock_execute.side_effect = self._mock_manager
yaml_data = r"""
yaml_data = """
---
XMChipStatsTable:
command: show xmchip {{ instance }} pt stats
Expand Down Expand Up @@ -675,7 +675,7 @@ def test_unstructured_ttpstatistics(self, mock_execute):
@patch("jnpr.junos.Device.execute")
def test_unstructured_mtip_cge_regex(self, mock_execute):
mock_execute.side_effect = self._mock_manager
yaml_data = r"""
yaml_data = """
---
MtipCgeSummaryTable:
command: show mtip-cge summary
Expand Down Expand Up @@ -877,7 +877,7 @@ def test_unstructured_icmpstats_nested(self, mock_execute):
@patch("jnpr.junos.Device.execute")
def test_unstructured_ithrottle_key_args(self, mock_execute):
mock_execute.side_effect = self._mock_manager
yaml_data = r"""
yaml_data = """
IthrottleIDTable:
command: show ithrottle id {{ id }}
args:
Expand Down Expand Up @@ -921,7 +921,7 @@ def test_unstructured_ithrottle_key_args(self, mock_execute):
@patch("jnpr.junos.Device.execute")
def test_pci_errs_multi_key_regex(self, mock_execute):
mock_execute.side_effect = self._mock_manager
yaml_data = r"""
yaml_data = """
---
ShowPciErrorsTable:
command: show pci errors {{ pci_controller_number }}
Expand Down Expand Up @@ -1024,7 +1024,7 @@ def test_fpcmemory_multi_key_columns(self, mock_execute):
@patch("jnpr.junos.Device.execute")
def test_item_regex_pq3_pci(self, mock_execute):
mock_execute.side_effect = self._mock_manager
yaml_data = r"""
yaml_data = """
---
PQ3PCITable:
command: show pq3 pci
Expand Down Expand Up @@ -1147,7 +1147,7 @@ def test_item_regex_pq3_pci(self, mock_execute):
@patch("jnpr.junos.Device.execute")
def test_regex_with_fields(self, mock_execute):
mock_execute.side_effect = self._mock_manager
yaml_data = r"""
yaml_data = """
---
SchedulerTable:
command: show sched
Expand Down Expand Up @@ -1252,7 +1252,7 @@ def test_table_path_option(self, mock_execute):
@patch("jnpr.junos.Device.execute")
def test_table_with_item_regex(self, mock_execute):
mock_execute.side_effect = self._mock_manager
yaml_data = r"""
yaml_data = """
---
DevicesLocalTable:
command: show devices local
Expand Down Expand Up @@ -1354,7 +1354,7 @@ def test_table_with_item_regex(self, mock_execute):
@patch("jnpr.junos.Device.execute")
def test_table_item_group_key_mismatch(self, mock_execute):
mock_execute.side_effect = self._mock_manager
yaml_data = r"""
yaml_data = """
---
DevicesLocalTable:
command: show devices local
Expand Down Expand Up @@ -1390,7 +1390,7 @@ def test_table_item_group_key_mismatch(self, mock_execute):
@patch("jnpr.junos.Device.execute")
def test_table_with_item_without_view(self, mock_execute):
mock_execute.side_effect = self._mock_manager
yaml_data = r"""
yaml_data = """
---
EthernetSwitchStatisticsIterTable:
command: show chassis ethernet-switch statistics
Expand Down Expand Up @@ -1629,7 +1629,7 @@ def test_title_without_view(self, mock_execute):
@patch("jnpr.junos.Device.execute")
def test_valueerror_with_no_target(self, mock_execute):
mock_execute.side_effect = self._mock_manager
yaml_data = r"""
yaml_data = """
---
ShowToePfePacketStatsTable:
command: show toe pfe {{ pfe_instance }} {{ asic_type }} {{ asic_instance }} toe-inst {{ toe_instance }} packet-stats
Expand Down Expand Up @@ -1697,7 +1697,7 @@ def test_valueerror_with_no_target(self, mock_execute):
@patch("jnpr.junos.Device.execute")
def test_item_with_fields_delimiter(self, mock_execute):
mock_execute.side_effect = self._mock_manager
yaml_data = r"""
yaml_data = """
---
ShowToePfePacketStatsTable:
command: show toe pfe {{ pfe_instance }} {{ asic_type }} {{ asic_instance }} toe-inst {{ toe_instance }} packet-stats
Expand Down Expand Up @@ -2300,7 +2300,7 @@ def test_table_eval_with_filters(self, mock_execute):
@patch("jnpr.junos.Device.execute")
def test_new_line_in_data(self, mock_execute):
mock_execute.side_effect = self._mock_manager
yaml_data = r"""
yaml_data = """
---
CChipLoStatsTable:
command: show xmchip {{ chip_instance }} lo stats 0
Expand Down
16 changes: 8 additions & 8 deletions tests/unit/test_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ def tearDownClass(cls):
def setUp(self, mock_write, mock_expect, mock_open):
tty_netconf.open = MagicMock()
mock_expect.side_effect = [
(1, re.search(r"(?P<login>ogin:\s*$)", "login: "), six.b("\r\r\n ogin:")),
(1, re.search("(?P<login>ogin:\s*$)", "login: "), six.b("\r\r\n ogin:")),
(
2,
re.search(r"(?P<passwd>assword:\s*$)", "password: "),
re.search("(?P<passwd>assword:\s*$)", "password: "),
six.b("\r\r\n password:"),
),
(
3,
re.search(r"(?P<shell>%|#\s*$)", "junos % "),
re.search("(?P<shell>%|#\s*$)", "junos % "),
six.b("\r\r\nroot@device:~ # "),
),
]
Expand Down Expand Up @@ -87,10 +87,10 @@ def test_telnet_old_fact_warning(self, mock_warn):
def test_login_bad_password(self, mock_write, mock_expect, mock_open):
tty_netconf.open = MagicMock()
mock_expect.side_effect = [
(1, re.search(r"(?P<login>ogin:\s*$)", "login: "), six.b("\r\r\n ogin:")),
(1, re.search("(?P<login>ogin:\s*$)", "login: "), six.b("\r\r\n ogin:")),
(
2,
re.search(r"(?P<passwd>assword:\s*$)", "password: "),
re.search("(?P<passwd>assword:\s*$)", "password: "),
six.b("\r\r\n password:"),
),
(
Expand All @@ -110,15 +110,15 @@ def test_with_context(self, mock_write, mock_expect, mock_open, mock_logout):
tty_netconf.open = MagicMock()

mock_expect.side_effect = [
(1, re.search(r"(?P<login>ogin:\s*$)", "login: "), six.b("\r\r\n ogin:")),
(1, re.search("(?P<login>ogin:\s*$)", "login: "), six.b("\r\r\n ogin:")),
(
2,
re.search(r"(?P<passwd>assword:\s*$)", "password: "),
re.search("(?P<passwd>assword:\s*$)", "password: "),
six.b("\r\r\n password:"),
),
(
3,
re.search(r"(?P<shell>%|#\s*$)", "junos % "),
re.search("(?P<shell>%|#\s*$)", "junos % "),
six.b("\r\r\nroot@device:~ # "),
),
]
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_rpcmeta.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def test_get_config_format_json_JSONLoadError_with_line(self):
except JSONLoadError as ex:
self.assertTrue(
re.search(
r"Expecting '?,'? delimiter: line 17 column 39 \(char 516\)",
"Expecting '?,'? delimiter: line 17 column 39 \(char 516\)",
ex.ex_msg,
)
is not None
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/utils/test_start_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def test_startshell_wait_for_regex(self, mock_select):
---(more)---
"""
self.assertTrue(
str(self.shell.wait_for(r"---\(more\s?\d*%?\)---\n\s*|%")[0])
str(self.shell.wait_for("---\(more\s?\d*%?\)---\n\s*|%")[0])
in self.shell._chan.recv.return_value
)

Expand All @@ -92,7 +92,7 @@ def test_startshell_run_regex(self, mock_wait_for):
"""
]
self.assertTrue(
self.shell.run("show version", r"---\(more\s?\d*%?\)---\n\s*|%")[0]
self.shell.run("show version", "---\(more\s?\d*%?\)---\n\s*|%")[0]
)

@patch("jnpr.junos.utils.start_shell.StartShell.wait_for")
Expand Down

0 comments on commit 3dbe7d9

Please sign in to comment.