]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
Revert most of "[1828] Make code safer by using with"
authorMukund Sivaraman <muks@isc.org>
Mon, 18 Jun 2012 18:35:03 +0000 (00:05 +0530)
committerMukund Sivaraman <muks@isc.org>
Mon, 18 Jun 2012 18:35:03 +0000 (00:05 +0530)
This reverts most of commit 57449046356fda9a21f3cf2dc1e5faadaaf42d7c.

src/bin/xfrout/tests/xfrout_test.py.in

index 6f38b75d4a920b6e71c63add575c34f1b6c281a2..bc409a87ded96ca56e10cb4ffe7e1fdb76d2fedf 100644 (file)
@@ -1196,30 +1196,31 @@ class TestUnixSockServer(unittest.TestCase):
         # We test with UDP, as it can be "connected" without other
         # endpoint.  Note that in the current implementation _guess_remote()
         # unconditionally returns SOCK_STREAM.
-        with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as sock:
-            sock.connect(('127.0.0.1', 12345))
-            self.assertEqual((socket.AF_INET, socket.SOCK_STREAM,
-                              ('127.0.0.1', 12345)),
-                             self.unix._guess_remote(sock.fileno()))
-
+        sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+        sock.connect(('127.0.0.1', 12345))
+        self.assertEqual((socket.AF_INET, socket.SOCK_STREAM,
+                          ('127.0.0.1', 12345)),
+                         self.unix._guess_remote(sock.fileno()))
+        sock.close()
         if socket.has_ipv6:
             # Don't check IPv6 address on hosts not supporting them
-            with socket.socket(socket.AF_INET6, socket.SOCK_DGRAM) as sock:
-                sock.connect(('::1', 12345))
-                self.assertEqual((socket.AF_INET6, socket.SOCK_STREAM,
-                                  ('::1', 12345, 0, 0)),
-                                 self.unix._guess_remote(sock.fileno()))
-
+            sock = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
+            sock.connect(('::1', 12345))
+            self.assertEqual((socket.AF_INET6, socket.SOCK_STREAM,
+                              ('::1', 12345, 0, 0)),
+                             self.unix._guess_remote(sock.fileno()))
+            sock.close()
             # Try when pretending there's no IPv6 support
             # (No need to pretend when there's really no IPv6)
             xfrout.socket.has_ipv6 = False
-            with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as sock:
-                sock.connect(('127.0.0.1', 12345))
-                self.assertEqual((socket.AF_INET, socket.SOCK_STREAM,
-                                  ('127.0.0.1', 12345)),
-                                 self.unix._guess_remote(sock.fileno()))
+            sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+            sock.connect(('127.0.0.1', 12345))
+            self.assertEqual((socket.AF_INET, socket.SOCK_STREAM,
+                              ('127.0.0.1', 12345)),
+                             self.unix._guess_remote(sock.fileno()))
             # Return it back
             xfrout.socket.has_ipv6 = True
+            sock.close()
 
     def test_receive_query_message(self):
         send_msg = b"\xd6=\x00\x00\x00\x01\x00"