]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix ResourceWarnings in test_pty
authorAntoine Pitrou <solipsis@pitrou.net>
Sun, 16 Dec 2012 15:09:11 +0000 (16:09 +0100)
committerAntoine Pitrou <solipsis@pitrou.net>
Sun, 16 Dec 2012 15:09:11 +0000 (16:09 +0100)
Lib/test/test_pty.py

index 4f1251cd3683758efa5f887abe3238c3c480553c..fcebce78e85dccb6eed0a008982b539419b4c697 100644 (file)
@@ -215,7 +215,7 @@ class SmallPtyTests(unittest.TestCase):
         for fd in self.fds:
             try:
                 os.close(fd)
-            except:
+            except OSError:
                 pass
 
     def _pipe(self):
@@ -235,8 +235,9 @@ class SmallPtyTests(unittest.TestCase):
         mock_stdin_fd, write_to_stdin_fd = self._pipe()
         pty.STDIN_FILENO = mock_stdin_fd
         socketpair = socket.socketpair()
+        for s in socketpair:
+            self.addCleanup(s.close)
         masters = [s.fileno() for s in socketpair]
-        self.fds.extend(masters)
 
         # Feed data.  Smaller than PIPEBUF.  These writes will not block.
         os.write(masters[1], b'from master')
@@ -264,8 +265,9 @@ class SmallPtyTests(unittest.TestCase):
         mock_stdin_fd, write_to_stdin_fd = self._pipe()
         pty.STDIN_FILENO = mock_stdin_fd
         socketpair = socket.socketpair()
+        for s in socketpair:
+            self.addCleanup(s.close)
         masters = [s.fileno() for s in socketpair]
-        self.fds.extend(masters)
 
         os.close(masters[1])
         socketpair[1].close()