@@ -1118,21 +1118,28 @@ async def test_keepalive_reports_errors(self):
11181118
11191119 async def test_close_timeout (self ):
11201120 """close_timeout parameter configures close timeout."""
1121- connection = Connection (Protocol (self .LOCAL ), close_timeout = 42 * MS )
1121+ connection = Connection (
1122+ Protocol (self .LOCAL ),
1123+ close_timeout = 42 * MS ,
1124+ )
11221125 self .assertEqual (connection .close_timeout , 42 * MS )
11231126
11241127 async def test_max_queue (self ):
11251128 """max_queue configures high-water mark of frames buffer."""
1126- connection = Connection (Protocol (self .LOCAL ), max_queue = 4 )
1127- transport = Mock ()
1128- connection .connection_made (transport )
1129+ connection = Connection (
1130+ Protocol (self .LOCAL ),
1131+ max_queue = 4 ,
1132+ )
1133+ connection .connection_made (Mock (spec = asyncio .Transport ))
11291134 self .assertEqual (connection .recv_messages .high , 4 )
11301135
11311136 async def test_max_queue_none (self ):
11321137 """max_queue disables high-water mark of frames buffer."""
1133- connection = Connection (Protocol (self .LOCAL ), max_queue = None )
1134- transport = Mock ()
1135- connection .connection_made (transport )
1138+ connection = Connection (
1139+ Protocol (self .LOCAL ),
1140+ max_queue = None ,
1141+ )
1142+ connection .connection_made (Mock (spec = asyncio .Transport ))
11361143 self .assertEqual (connection .recv_messages .high , None )
11371144 self .assertEqual (connection .recv_messages .low , None )
11381145
@@ -1142,8 +1149,7 @@ async def test_max_queue_tuple(self):
11421149 Protocol (self .LOCAL ),
11431150 max_queue = (4 , 2 ),
11441151 )
1145- transport = Mock ()
1146- connection .connection_made (transport )
1152+ connection .connection_made (Mock (spec = asyncio .Transport ))
11471153 self .assertEqual (connection .recv_messages .high , 4 )
11481154 self .assertEqual (connection .recv_messages .low , 2 )
11491155
@@ -1153,7 +1159,7 @@ async def test_write_limit(self):
11531159 Protocol (self .LOCAL ),
11541160 write_limit = 4096 ,
11551161 )
1156- transport = Mock ()
1162+ transport = Mock (spec = asyncio . Transport )
11571163 connection .connection_made (transport )
11581164 transport .set_write_buffer_limits .assert_called_once_with (4096 , None )
11591165
@@ -1163,7 +1169,7 @@ async def test_write_limits(self):
11631169 Protocol (self .LOCAL ),
11641170 write_limit = (4096 , 2048 ),
11651171 )
1166- transport = Mock ()
1172+ transport = Mock (spec = asyncio . Transport )
11671173 connection .connection_made (transport )
11681174 transport .set_write_buffer_limits .assert_called_once_with (4096 , 2048 )
11691175
@@ -1177,13 +1183,13 @@ async def test_logger(self):
11771183 """Connection has a logger attribute."""
11781184 self .assertIsInstance (self .connection .logger , logging .LoggerAdapter )
11791185
1180- @patch ("asyncio.BaseTransport .get_extra_info" , return_value = ("sock" , 1234 ))
1186+ @patch ("asyncio.Transport .get_extra_info" , return_value = ("sock" , 1234 ))
11811187 async def test_local_address (self , get_extra_info ):
11821188 """Connection provides a local_address attribute."""
11831189 self .assertEqual (self .connection .local_address , ("sock" , 1234 ))
11841190 get_extra_info .assert_called_with ("sockname" )
11851191
1186- @patch ("asyncio.BaseTransport .get_extra_info" , return_value = ("peer" , 1234 ))
1192+ @patch ("asyncio.Transport .get_extra_info" , return_value = ("peer" , 1234 ))
11871193 async def test_remote_address (self , get_extra_info ):
11881194 """Connection provides a remote_address attribute."""
11891195 self .assertEqual (self .connection .remote_address , ("peer" , 1234 ))
0 commit comments