summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorChristian Heimes <christian@python.org>2016-09-11 17:49:56 (GMT)
committerChristian Heimes <christian@python.org>2016-09-11 17:49:56 (GMT)
commit02b3035bc30095d63af5c6ddd8b5ae605305b395 (patch)
treed3c4847c9645bdbe173a591688b904c11d625282 /Lib/test
parent015d8746261f23084d449ae9f382d7088ec7016f (diff)
downloadcpython-02b3035bc30095d63af5c6ddd8b5ae605305b395.zip
cpython-02b3035bc30095d63af5c6ddd8b5ae605305b395.tar.gz
cpython-02b3035bc30095d63af5c6ddd8b5ae605305b395.tar.bz2
Issue #28078: Silence resource warnings in test_socket. Initial patch by Xiang Zhang, thanks
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_socket.py26
1 files changed, 15 insertions, 11 deletions
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
index b3632e9..8fc7290 100644
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -5347,8 +5347,10 @@ class LinuxKernelCryptoAPI(unittest.TestCase):
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 @@ class LinuxKernelCryptoAPI(unittest.TestCase):
def test_sendmsg_afalg_args(self):
sock = socket.socket(socket.AF_ALG, socket.SOCK_SEQPACKET, 0)
- with self.assertRaises(TypeError):
- sock.sendmsg_afalg()
+ 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(op=None)
+ with self.assertRaises(TypeError):
+ sock.sendmsg_afalg(1)
- 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=None)
+ with self.assertRaises(TypeError):
+ sock.sendmsg_afalg(op=socket.ALG_OP_ENCRYPT, assoclen=-1)
- with self.assertRaises(TypeError):
- sock.sendmsg_afalg(op=socket.ALG_OP_ENCRYPT, assoclen=-1)
def test_main():
tests = [GeneralModuleTests, BasicTCPTest, TCPCloserTest, TCPTimeoutTest,