[Python-checkins] cpython: Issue #28078: Silence resource warnings in test_socket. Initial patch by Xiang
christian.heimes
python-checkins at python.org
Sun Sep 11 13:50:01 EDT 2016
https://hg.python.org/cpython/rev/c515bc3b29bf
changeset: 103643:c515bc3b29bf
user: Christian Heimes <christian at python.org>
date: Sun Sep 11 19:49:56 2016 +0200
summary:
Issue #28078: Silence resource warnings in test_socket. Initial patch by Xiang Zhang, thanks
files:
Lib/test/test_socket.py | 34 ++++++++++++++++------------
1 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -5347,8 +5347,10 @@
sock.bind((typ, name))
except FileNotFoundError as e:
# type / algorithm is not available
+ sock.close()
raise unittest.SkipTest(str(e), typ, name)
- return sock
+ else
+ return sock
def test_sha256(self):
expected = bytes.fromhex("ba7816bf8f01cfea414140de5dae2223b00361a396"
@@ -5494,20 +5496,22 @@
def test_sendmsg_afalg_args(self):
sock = socket.socket(socket.AF_ALG, socket.SOCK_SEQPACKET, 0)
- with self.assertRaises(TypeError):
- sock.sendmsg_afalg()
-
- with self.assertRaises(TypeError):
- sock.sendmsg_afalg(op=None)
-
- with self.assertRaises(TypeError):
- sock.sendmsg_afalg(1)
-
- with self.assertRaises(TypeError):
- sock.sendmsg_afalg(op=socket.ALG_OP_ENCRYPT, assoclen=None)
-
- with self.assertRaises(TypeError):
- sock.sendmsg_afalg(op=socket.ALG_OP_ENCRYPT, assoclen=-1)
+ with sock:
+ with self.assertRaises(TypeError):
+ sock.sendmsg_afalg()
+
+ with self.assertRaises(TypeError):
+ sock.sendmsg_afalg(op=None)
+
+ with self.assertRaises(TypeError):
+ sock.sendmsg_afalg(1)
+
+ with self.assertRaises(TypeError):
+ sock.sendmsg_afalg(op=socket.ALG_OP_ENCRYPT, assoclen=None)
+
+ with self.assertRaises(TypeError):
+ sock.sendmsg_afalg(op=socket.ALG_OP_ENCRYPT, assoclen=-1)
+
def test_main():
tests = [GeneralModuleTests, BasicTCPTest, TCPCloserTest, TCPTimeoutTest,
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list