Skip to content

Commit

Permalink
Add detailed reason for assert failure (sonic-net#12997)
Browse files Browse the repository at this point in the history
What is the motivation for this PR?
Add useful information about failed reason.

How did you do it?
Add the message parameter in pytest_assert

How did you verify/test it?
Run ssh.test_ssh_limit.
  • Loading branch information
ZhaohuiS authored and mssonicbld committed May 28, 2024
1 parent 164761d commit 749ddc9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tests/ssh/test_ssh_limit.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,16 @@ def test_ssh_limits(duthosts, rand_one_dut_hostname, tacacs_creds, setup_limit):
login_message_1 = get_login_result(ssh_session_1)

logging.debug("Login session 1 result:\n{0}\n".format(login_message_1))
pytest_assert("There were too many logins for" not in login_message_1)
pytest_assert("There were too many logins for" not in login_message_1,
"The first login was rejected due to too many logins")

# The second session will be disconnect by device
ssh_session_2 = paramiko_ssh(dut_ip, local_user, local_user_password)
login_message_2 = get_login_result(ssh_session_2)

logging.debug("Login session 2 result:\n{0}\n".format(login_message_2))
pytest_assert("There were too many logins for" in login_message_2)
pytest_assert("There were too many logins for" in login_message_2,
"The second login was not rejected by ssh limit")

ssh_session_1.close()
ssh_session_2.close()

0 comments on commit 749ddc9

Please sign in to comment.