11#!/usr/bin/env python
2- # -*- coding: utf-8 -*-
32
43
54""" Unit tests for zeroconf._services.browser. """
@@ -682,7 +681,7 @@ def on_service_state_change(zeroconf, service_type, state_change, name):
682681
683682 info_service = ServiceInfo (
684683 type_ ,
685- '%s.%s' % ( name , type_ ) ,
684+ f' { name } . { type_ } ' ,
686685 80 ,
687686 0 ,
688687 0 ,
@@ -902,7 +901,7 @@ def test_group_ptr_queries_with_known_answers():
902901 now = current_time_millis ()
903902 for i in range (120 ):
904903 name = f"_hap{ i } ._tcp._local."
905- questions_with_known_answers [DNSQuestion (name , const ._TYPE_PTR , const ._CLASS_IN )] = set (
904+ questions_with_known_answers [DNSQuestion (name , const ._TYPE_PTR , const ._CLASS_IN )] = {
906905 DNSPointer (
907906 name ,
908907 const ._TYPE_PTR ,
@@ -911,7 +910,7 @@ def test_group_ptr_queries_with_known_answers():
911910 f"zoo{ counter } .{ name } " ,
912911 )
913912 for counter in range (i )
914- )
913+ }
915914 outs = _services_browser ._group_ptr_queries_with_known_answers (now , True , questions_with_known_answers )
916915 for out in outs :
917916 packets = out .packets ()
@@ -937,7 +936,7 @@ async def test_generate_service_query_suppress_duplicate_questions():
937936 10000 ,
938937 f'known-to-other.{ name } ' ,
939938 )
940- other_known_answers = set ([ answer ])
939+ other_known_answers = { answer }
941940 zc .question_history .add_question_at_time (question , now , other_known_answers )
942941 assert zc .question_history .suppresses (question , now , other_known_answers )
943942
@@ -976,16 +975,16 @@ async def test_generate_service_query_suppress_duplicate_questions():
976975@pytest .mark .asyncio
977976async def test_query_scheduler ():
978977 delay = const ._BROWSER_TIME
979- types_ = set ([ "_hap._tcp.local." , "_http._tcp.local." ])
978+ types_ = { "_hap._tcp.local." , "_http._tcp.local." }
980979 query_scheduler = _services_browser .QueryScheduler (types_ , delay , (0 , 0 ))
981980
982981 now = current_time_millis ()
983982 query_scheduler .start (now )
984983
985984 # Test query interval is increasing
986985 assert query_scheduler .millis_to_wait (now - 1 ) == 1
987- assert query_scheduler .millis_to_wait (now ) is 0
988- assert query_scheduler .millis_to_wait (now + 1 ) is 0
986+ assert query_scheduler .millis_to_wait (now ) == 0
987+ assert query_scheduler .millis_to_wait (now + 1 ) == 0
989988
990989 assert set (query_scheduler .process_ready_types (now )) == types_
991990 assert set (query_scheduler .process_ready_types (now )) == set ()
@@ -1013,8 +1012,8 @@ async def test_query_scheduler():
10131012 assert set (query_scheduler .process_ready_types (now + delay * 15 )) == set ()
10141013
10151014 # Test if we reschedule 1 second later... and its ready for processing
1016- assert set (query_scheduler .process_ready_types (now + delay * 16 )) == set ([ "_hap._tcp.local." ])
1015+ assert set (query_scheduler .process_ready_types (now + delay * 16 )) == { "_hap._tcp.local." }
10171016 assert query_scheduler .millis_to_wait (now ) == pytest .approx (delay * 31 , 0.00001 )
10181017 assert set (query_scheduler .process_ready_types (now + delay * 20 )) == set ()
10191018
1020- assert set (query_scheduler .process_ready_types (now + delay * 31 )) == set ([ "_http._tcp.local." ])
1019+ assert set (query_scheduler .process_ready_types (now + delay * 31 )) == { "_http._tcp.local." }
0 commit comments