@@ -169,12 +169,19 @@ def patched_create_connection(address, *args, **kwargs):
169169 with mock .patch ('socket.create_connection' , patched_create_connection ):
170170 with check_no_resource_warning (self ):
171171 # Try without CacheFTPHandler
172+ warnings .filterwarnings ('error' , category = ResourceWarning )
172173 self ._test_urls ([entry ], handlers = no_cache_handlers )
173174 with check_no_resource_warning (self ):
174- # Try with CacheFTPHandler (uncached & cached)
175- self ._test_urls ([entry , entry ], cache_handlers )
175+ # Try with CacheFTPHandler (uncached)
176+ warnings .filterwarnings ('error' , category = ResourceWarning )
177+ self ._test_urls ([entry ], cache_handlers )
178+ with check_no_resource_warning (self ):
179+ # Try with CacheFTPHandler (cached)
180+ warnings .filterwarnings ('error' , category = ResourceWarning )
181+ self ._test_urls ([entry ], cache_handlers )
176182 # Try without the mock: the handler should not use a closed connection
177183 with check_no_resource_warning (self ):
184+ warnings .filterwarnings ('error' , category = ResourceWarning )
178185 self ._test_urls ([url ], cache_handlers )
179186
180187 def test_file (self ):
0 commit comments