bpo-22831: Use "with" to avoid possible fd leaks in tests (part 2). (GH-10929)

diff --git a/Lib/test/test_poll.py b/Lib/test/test_poll.py
index 445032d..ef966bf 100644
--- a/Lib/test/test_poll.py
+++ b/Lib/test/test_poll.py
@@ -83,13 +83,12 @@
         r = p.poll()
         self.assertEqual(r[0], (FD, select.POLLNVAL))
 
-        f = open(TESTFN, 'w')
-        fd = f.fileno()
-        p = select.poll()
-        p.register(f)
-        r = p.poll()
-        self.assertEqual(r[0][0], fd)
-        f.close()
+        with open(TESTFN, 'w') as f:
+            fd = f.fileno()
+            p = select.poll()
+            p.register(f)
+            r = p.poll()
+            self.assertEqual(r[0][0], fd)
         r = p.poll()
         self.assertEqual(r[0], (fd, select.POLLNVAL))
         os.unlink(TESTFN)