Skip to content

Commit

Permalink
Improve Juniper config_mode pattern (#2762)
Browse files Browse the repository at this point in the history
Fix some minor test issues
  • Loading branch information
ktbyers committed Apr 27, 2022
1 parent 3ad6c6e commit 765f432
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
8 changes: 6 additions & 2 deletions netmiko/juniper/juniper.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,14 @@ def check_config_mode(
def config_mode(
self,
config_command: str = "configure",
pattern: str = r"Entering configuration mode",
pattern: str = r"(?s)Entering configuration mode.*\].*#",
re_flags: int = 0,
) -> str:
"""Enter configuration mode."""
"""
Enter configuration mode.
(?s) enables re.DOTALL in regex pattern.
"""
return super().config_mode(
config_command=config_command, pattern=pattern, re_flags=re_flags
)
Expand Down
11 changes: 7 additions & 4 deletions tests/SLOG/netmiko.log
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ write_channel: b'********\n'
read_channel:
read_channel:
read_channel:
read_channel:
cisco1#
Pattern found: (cisco1) :
cisco1
Expand All @@ -28,9 +29,10 @@ cisco1#
read_channel:
write_channel: b'\n'
read_channel:
cisco1#
read_channel:
read_channel:
cisco1#
Pattern found: ([>#])
cisco1#
write_channel: b'exit\n'
write_channel: b'terminal width 511\n'
read_channel:
Expand Down Expand Up @@ -117,7 +119,8 @@ Pattern found: (show\ ip\ interface\ brief) show ip interface brief
read_channel:
write_channel: b'\n'
read_channel:
cisco1>
read_channel:
read_channel:
cisco1>
Pattern found: ([>#])
cisco1>
write_channel: b'exit\n'
6 changes: 3 additions & 3 deletions tests/run_live_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ cd ..
cd test_juniper_junos
./test_juniper_junos.sh > ../test_out/test_juniper_junos.out 2> ../test_out/test_juniper_junos.stderr &

cd ..
cd test_cisco_asa
./test_cisco_asa.sh > ../test_out/test_cisco_asa.out 2> ../test_out/test_cisco_asa.stderr &
# cd ..
# cd test_cisco_asa
# ./test_cisco_asa.sh > ../test_out/test_cisco_asa.out 2> ../test_out/test_cisco_asa.stderr &
2 changes: 1 addition & 1 deletion tests/test_timeout_send_command_timing.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_read_show_tech(net_connect_newconn):

read_timeout = 0
output, exec_time = execute_cmd(
net_connect_newconn, read_timeout=read_timeout, last_read=4.0
net_connect_newconn, read_timeout=read_timeout, last_read=8.0
)
assert "show interface" in output
assert "cisco3#" in output
Expand Down

0 comments on commit 765f432

Please sign in to comment.