From: Giampaolo RodolĂ  Date: Tue, 8 Mar 2011 20:33:21 +0000 (+0100) Subject: #8594: fix ResourceWarning in test_ftplib.py - patch by Nadeem Vawda. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7a2114719dd7403cacf1e133b2f7414eaab24188;p=python #8594: fix ResourceWarning in test_ftplib.py - patch by Nadeem Vawda. --- diff --git a/Lib/test/test_ftplib.py b/Lib/test/test_ftplib.py index 5f8a8bde44..127b1b956f 100644 --- a/Lib/test/test_ftplib.py +++ b/Lib/test/test_ftplib.py @@ -619,8 +619,8 @@ class TestFTPClass(TestCase): def test_source_address_passive_connection(self): port = support.find_unused_port() self.client.source_address = (HOST, port) - sock = self.client.transfercmd('list') - self.assertEqual(sock.getsockname()[1], port) + with self.client.transfercmd('list') as sock: + self.assertEqual(sock.getsockname()[1], port) def test_parse257(self): self.assertEqual(ftplib.parse257('257 "/foo/bar"'), '/foo/bar')