@@ -141,20 +141,20 @@ def test_dns_outgoing_repr(self):
141141class PacketGeneration (unittest .TestCase ):
142142 def test_parse_own_packet_simple (self ):
143143 generated = r .DNSOutgoing (0 )
144- r .DNSIncoming (generated .packet () )
144+ r .DNSIncoming (generated .packets ()[ 0 ] )
145145
146146 def test_parse_own_packet_simple_unicast (self ):
147147 generated = r .DNSOutgoing (0 , False )
148- r .DNSIncoming (generated .packet () )
148+ r .DNSIncoming (generated .packets ()[ 0 ] )
149149
150150 def test_parse_own_packet_flags (self ):
151151 generated = r .DNSOutgoing (const ._FLAGS_QR_QUERY )
152- r .DNSIncoming (generated .packet () )
152+ r .DNSIncoming (generated .packets ()[ 0 ] )
153153
154154 def test_parse_own_packet_question (self ):
155155 generated = r .DNSOutgoing (const ._FLAGS_QR_QUERY )
156156 generated .add_question (r .DNSQuestion ("testname.local." , const ._TYPE_SRV , const ._CLASS_IN ))
157- r .DNSIncoming (generated .packet () )
157+ r .DNSIncoming (generated .packets ()[ 0 ] )
158158
159159 def test_parse_own_packet_response (self ):
160160 generated = r .DNSOutgoing (const ._FLAGS_QR_RESPONSE )
@@ -171,15 +171,15 @@ def test_parse_own_packet_response(self):
171171 ),
172172 0 ,
173173 )
174- parsed = r .DNSIncoming (generated .packet () )
174+ parsed = r .DNSIncoming (generated .packets ()[ 0 ] )
175175 assert len (generated .answers ) == 1
176176 assert len (generated .answers ) == len (parsed .answers )
177177
178178 def test_match_question (self ):
179179 generated = r .DNSOutgoing (const ._FLAGS_QR_QUERY )
180180 question = r .DNSQuestion ("testname.local." , const ._TYPE_SRV , const ._CLASS_IN )
181181 generated .add_question (question )
182- parsed = r .DNSIncoming (generated .packet () )
182+ parsed = r .DNSIncoming (generated .packets ()[ 0 ] )
183183 assert len (generated .questions ) == 1
184184 assert len (generated .questions ) == len (parsed .questions )
185185 assert question == parsed .questions [0 ]
@@ -220,7 +220,7 @@ def test_suppress_answer(self):
220220 )
221221 query_generated .add_answer_at_time (answer1 , 0 )
222222 query_generated .add_answer_at_time (staleanswer2 , 0 )
223- query = r .DNSIncoming (query_generated .packet () )
223+ query = r .DNSIncoming (query_generated .packets ()[ 0 ] )
224224
225225 # Should be suppressed
226226 response = r .DNSOutgoing (const ._FLAGS_QR_RESPONSE )
@@ -255,14 +255,14 @@ def test_suppress_answer(self):
255255 def test_dns_hinfo (self ):
256256 generated = r .DNSOutgoing (0 )
257257 generated .add_additional_answer (DNSHinfo ('irrelevant' , const ._TYPE_HINFO , 0 , 0 , 'cpu' , 'os' ))
258- parsed = r .DNSIncoming (generated .packet () )
258+ parsed = r .DNSIncoming (generated .packets ()[ 0 ] )
259259 answer = cast (r .DNSHinfo , parsed .answers [0 ])
260260 assert answer .cpu == u'cpu'
261261 assert answer .os == u'os'
262262
263263 generated = r .DNSOutgoing (0 )
264264 generated .add_additional_answer (DNSHinfo ('irrelevant' , const ._TYPE_HINFO , 0 , 0 , 'cpu' , 'x' * 257 ))
265- self .assertRaises (r .NamePartTooLongException , generated .packet )
265+ self .assertRaises (r .NamePartTooLongException , generated .packets )
266266
267267 def test_many_questions (self ):
268268 """Test many questions get seperated into multiple packets."""
@@ -290,7 +290,7 @@ def test_only_one_answer_can_by_large(self):
290290 https://datatracker.ietf.org/doc/html/rfc6762#section-17
291291 """
292292 generated = r .DNSOutgoing (const ._FLAGS_QR_RESPONSE )
293- query = r .DNSIncoming (r .DNSOutgoing (const ._FLAGS_QR_QUERY ).packet () )
293+ query = r .DNSIncoming (r .DNSOutgoing (const ._FLAGS_QR_QUERY ).packets ()[ 0 ] )
294294 for i in range (3 ):
295295 generated .add_answer (
296296 query ,
@@ -381,25 +381,25 @@ class PacketForm(unittest.TestCase):
381381 def test_transaction_id (self ):
382382 """ID must be zero in a DNS-SD packet"""
383383 generated = r .DNSOutgoing (const ._FLAGS_QR_QUERY )
384- bytes = generated .packet ()
384+ bytes = generated .packets ()[ 0 ]
385385 id = bytes [0 ] << 8 | bytes [1 ]
386386 assert id == 0
387387
388388 def test_query_header_bits (self ):
389389 generated = r .DNSOutgoing (const ._FLAGS_QR_QUERY )
390- bytes = generated .packet ()
390+ bytes = generated .packets ()[ 0 ]
391391 flags = bytes [2 ] << 8 | bytes [3 ]
392392 assert flags == 0x0
393393
394394 def test_response_header_bits (self ):
395395 generated = r .DNSOutgoing (const ._FLAGS_QR_RESPONSE )
396- bytes = generated .packet ()
396+ bytes = generated .packets ()[ 0 ]
397397 flags = bytes [2 ] << 8 | bytes [3 ]
398398 assert flags == 0x8000
399399
400400 def test_numbers (self ):
401401 generated = r .DNSOutgoing (const ._FLAGS_QR_RESPONSE )
402- bytes = generated .packet ()
402+ bytes = generated .packets ()[ 0 ]
403403 (num_questions , num_answers , num_authorities , num_additionals ) = struct .unpack ('!4H' , bytes [4 :12 ])
404404 assert num_questions == 0
405405 assert num_answers == 0
@@ -411,7 +411,7 @@ def test_numbers_questions(self):
411411 question = r .DNSQuestion ("testname.local." , const ._TYPE_SRV , const ._CLASS_IN )
412412 for i in range (10 ):
413413 generated .add_question (question )
414- bytes = generated .packet ()
414+ bytes = generated .packets ()[ 0 ]
415415 (num_questions , num_answers , num_authorities , num_additionals ) = struct .unpack ('!4H' , bytes [4 :12 ])
416416 assert num_questions == 10
417417 assert num_answers == 0
@@ -422,7 +422,7 @@ def test_numbers_questions(self):
422422class TestDnsIncoming (unittest .TestCase ):
423423 def test_incoming_exception_handling (self ):
424424 generated = r .DNSOutgoing (0 )
425- packet = generated .packet ()
425+ packet = generated .packets ()[ 0 ]
426426 packet = packet [:8 ] + b'deadbeef' + packet [8 :]
427427 parsed = r .DNSIncoming (packet )
428428 parsed = r .DNSIncoming (packet )
@@ -432,7 +432,7 @@ def test_incoming_unknown_type(self):
432432 generated = r .DNSOutgoing (0 )
433433 answer = r .DNSAddress ('a' , const ._TYPE_SOA , const ._CLASS_IN , 1 , b'a' )
434434 generated .add_additional_answer (answer )
435- packet = generated .packet ()
435+ packet = generated .packets ()[ 0 ]
436436 parsed = r .DNSIncoming (packet )
437437 assert len (parsed .answers ) == 0
438438 assert parsed .is_query () != parsed .is_response ()
@@ -443,7 +443,7 @@ def test_incoming_ipv6(self):
443443 generated = r .DNSOutgoing (0 )
444444 answer = r .DNSAddress ('domain' , const ._TYPE_AAAA , const ._CLASS_IN | const ._CLASS_UNIQUE , 1 , packed )
445445 generated .add_additional_answer (answer )
446- packet = generated .packet ()
446+ packet = generated .packets ()[ 0 ]
447447 parsed = r .DNSIncoming (packet )
448448 record = parsed .answers [0 ]
449449 assert isinstance (record , r .DNSAddress )
0 commit comments