Skip to content

Commit

Permalink
Call duthost_console fixture for test_escape_character test case (#8733)
Browse files Browse the repository at this point in the history
* Call duthost_console fixture for test_escape_character
* Fix for test_escape_character - dut_console
  • Loading branch information
sanjair-git authored Jul 25, 2023
1 parent 760a9eb commit 63f7512
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions tests/dut_console/test_escape_character.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
import pexpect
import logging
import time
import re
import pytest
import six

from tests.common.helpers.assertions import pytest_assert

TOTAL_PACKETS = 100
packet_number = 10
logger = logging.getLogger(__name__)

pytestmark = [
pytest.mark.topology('any')
]


def test_console_escape():
child = pexpect.spawn("ping 127.0.0.1 -c {} -i 1".format(TOTAL_PACKETS))
time.sleep(5)
child.sendcontrol('C')
child.expect(r"\^C")
match = re.search(r'(\d) packets transmitted', six.ensure_text(child.read()))
pytest_assert(int(match.group(1)) < TOTAL_PACKETS, "Escape Character does not work.")
def test_console_escape(duthost_console):
duthost_console.send_command("ping 127.0.0.1 -c {} -i 1".format(TOTAL_PACKETS),
expect_string=r"icmp_seq={}".format(packet_number))
duthost_console.send_command("\x03",
expect_string=r"{} packets transmitted".format(packet_number), max_loops=300)

0 comments on commit 63f7512

Please sign in to comment.