This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Silence resource warnings in test_socket
Type: behavior Stage: resolved
Components: Tests Versions: Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: christian.heimes, python-dev, xiang.zhang
Priority: normal Keywords: patch

Created on 2016-09-11 15:47 by xiang.zhang, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
test_socket.patch xiang.zhang, 2016-09-11 15:48 review
Messages (8)
msg275803 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2016-09-11 15:47
test_aead_aes_gcm (test.test_socket.LinuxKernelCryptoAPI) ... /home/angwer/cpython/Lib/unittest/case.py:600: ResourceWarning: unclosed <socket.socket fd=3, family=AddressFamily.AF_ALG, type=SocketKind.SOCK_SEQPACKET, proto=0>
  testMethod()
skipped "('[Errno 2] No such file or directory', 'aead', 'gcm(aes)')"
test_sendmsg_afalg_args (test.test_socket.LinuxKernelCryptoAPI) ... /home/angwer/cpython/Lib/unittest/case.py:600: ResourceWarning: unclosed <socket.socket fd=3, family=AddressFamily.AF_ALG, type=SocketKind.SOCK_SEQPACKET, proto=0>
  testMethod()
ok

Christian, after issue27744, there are 2 resource warnings in test_socket. test_socket.patch eliminates them.
msg275805 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2016-09-11 16:36
Thanks! The first fix looks good. For the second one I'd rather wrap the test body in a with statement:

    def test_sendmsg_afalg_args(self):
        sock = socket.socket(socket.AF_ALG, socket.SOCK_SEQPACKET, 0)
        with sock:
            with self.assertRaises(TypeError):
                sock.sendmsg_afalg()
            ...
msg275806 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2016-09-11 16:40
It's your code. Do what you like. :)
msg275814 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-09-11 17:50
New changeset c515bc3b29bf by Christian Heimes in branch 'default':
Issue #28078: Silence resource warnings in test_socket. Initial patch by Xiang Zhang, thanks
https://hg.python.org/cpython/rev/c515bc3b29bf
msg275815 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2016-09-11 17:50
Thanks for the report and your patch. Let's watch the build bot.
msg275818 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2016-09-11 18:01
Christian, you forget a : after else.
msg275819 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-09-11 18:03
New changeset 8b655668c04f by Christian Heimes in branch 'default':
Issue #28078: Add missing colon
https://hg.python.org/cpython/rev/8b655668c04f
msg275821 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2016-09-11 18:06
Oh heck! I'm not sure what happened here. The test was passing locally. I can only assume that I accidentally modified the file between test run and commit.
History
Date User Action Args
2022-04-11 14:58:36adminsetgithub: 72265
2016-09-12 02:36:52xiang.zhangsetstatus: open -> closed
resolution: fixed
stage: commit review -> resolved
2016-09-11 18:06:30christian.heimessetmessages: + msg275821
2016-09-11 18:03:54python-devsetmessages: + msg275819
2016-09-11 18:01:59xiang.zhangsetstatus: pending -> open

messages: + msg275818
2016-09-11 17:50:44christian.heimessetstatus: open -> pending

messages: + msg275815
stage: patch review -> commit review
2016-09-11 17:50:04python-devsetnosy: + python-dev
messages: + msg275814
2016-09-11 16:40:52xiang.zhangsetmessages: + msg275806
2016-09-11 16:36:18christian.heimessetmessages: + msg275805
2016-09-11 15:48:03xiang.zhangsetfiles: + test_socket.patch
keywords: + patch
2016-09-11 15:47:32xiang.zhangcreate