<s> import binascii <EOL> import pytest <EOL> import pyshark <EOL> @ pytest . fixture <EOL> def inmem_capture ( ) : <EOL> return pyshark . InMemCapture ( ) <EOL> def arp_packet ( last_byte = '<STR_LIT:f>' ) : <EOL> """<STR_LIT>""" <EOL> p = "<STR_LIT>" % last_byte <EOL> return binascii . unhexlify ( p ) <EOL> def test_can_read_binary_packet ( inmem_capture ) : <EOL> pkt = inmem_capture . feed_packet ( arp_packet ( '<STR_LIT:f>' ) ) <EOL> assert pkt . eth . src == '<STR_LIT>' <EOL> def test_can_read_multiple_binary_packet ( inmem_capture ) : <EOL> pkts = inmem_capture . feed_packets ( [ arp_packet ( '<STR_LIT:1>' ) , arp_packet ( '<STR_LIT:2>' ) , arp_packet ( '<STR_LIT:3>' ) ] ) <EOL> assert len ( pkts ) == <NUM_LIT:3> <EOL> for i , pkt in enumerate ( pkts ) : <EOL> assert pkt . eth . src == '<STR_LIT>' + str ( i + <NUM_LIT:1> ) <EOL> def test_fed_packets_are_added_to_the_list ( inmem_capture ) : <EOL> inmem_capture . feed_packet ( arp_packet ( ) ) <EOL> assert len ( inmem_capture ) == <NUM_LIT:1> <EOL> inmem_capture . feed_packets ( [ arp_packet ( ) , arp_packet ( ) ] ) <EOL> assert len ( inmem_capture ) == <NUM_LIT:3> </s>
