Skip to content

Commit

Permalink
fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
polybassa committed Sep 23, 2024
1 parent fdb2b31 commit 76f860a
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/testsocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,25 @@ def __exit__(self, exc_type, exc_value, traceback):
"""Close the socket"""
self.close()

def sr(self, *args, **kargs):
# type: (Any, Any) -> Tuple[SndRcvList, PacketList]
"""Send and Receive multiple packets
"""
from scapy import sendrecv
return sendrecv.sndrcv(self, *args, threaded=False, **kargs)

def sr1(self, *args, **kargs):
# type: (Any, Any) -> Optional[Packet]
"""Send one packet and receive one answer
"""
from scapy import sendrecv
ans = sendrecv.sndrcv(self, *args, threaded=False, **kargs)[0] # type: SndRcvList
if len(ans) > 0:
pkt = ans[0][1] # type: Packet
return pkt
else:
return None

def close(self):
# type: () -> None
global open_test_sockets
Expand Down

0 comments on commit 76f860a

Please sign in to comment.