diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-12-16 15:09:11 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-12-16 15:09:11 (GMT) |
commit | 697ce5560fec5bb3207f3d975e34dc6a702016ec (patch) | |
tree | df1a6945a39c5c6e5e5f6535c643661c8b7a7520 /Lib/test/test_pty.py | |
parent | 5461558d1ab5809c44d02f5e8669aca64ec07404 (diff) | |
download | cpython-697ce5560fec5bb3207f3d975e34dc6a702016ec.zip cpython-697ce5560fec5bb3207f3d975e34dc6a702016ec.tar.gz cpython-697ce5560fec5bb3207f3d975e34dc6a702016ec.tar.bz2 |
Fix ResourceWarnings in test_pty
Diffstat (limited to 'Lib/test/test_pty.py')
-rw-r--r-- | Lib/test/test_pty.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/test/test_pty.py b/Lib/test/test_pty.py index 4f1251c..fcebce7 100644 --- a/Lib/test/test_pty.py +++ b/Lib/test/test_pty.py @@ -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() |