classification
Title: Add helper to check that no ResourceWarning is emitted
Type: enhancement Stage: resolved
Components: Tests Versions: Python 3.6, Python 3.5, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: martin.panter, python-dev, serhiy.storchaka, vstinner
Priority: normal Keywords: patch

Created on 2016-02-10 10:14 by serhiy.storchaka, last changed 2016-02-11 11:38 by serhiy.storchaka. This issue is now closed.

Files
File name Uploaded Description Edit
test_support_check_no_resource_warning.patch serhiy.storchaka, 2016-02-10 10:14 review
test_support_check_no_resource_warning_2.patch serhiy.storchaka, 2016-02-10 11:13 review
Messages (6)
msg260000 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-02-10 10:14
Victor proposed in issue25994 to use special context manager to check that no ResourceWarning is emitted. I think that this helper can be useful in other tests. It saves 3 lines for every use. Proposed patch adds it in test.support.
msg260001 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2016-02-10 10:26
Oh, I didn't expect that so many existing test already use the same pattern to check for ResourceWarning. Nice patch!

I added a comment: we must be careful in the documentation of the helper.
msg260002 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-02-10 10:37
I was about to suggest adding this to test.support as well. Patch looks good to me.
msg260005 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-02-10 11:13
Addressed Victor's comments.

This pattern is not widely used. Usually only raising ResourceWarning is tested, but not non-raising.
msg260040 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2016-02-10 21:56
test_support_check_no_resource_warning_2.patch LGTM, thanks.
msg260086 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-02-11 11:12
New changeset e9a4b30e3e43 by Serhiy Storchaka in branch '3.5':
Issue #26325: Added test.support.check_no_resource_warning() to check that
https://hg.python.org/cpython/rev/e9a4b30e3e43

New changeset faf676d8c054 by Serhiy Storchaka in branch 'default':
Issue #26325: Added test.support.check_no_resource_warning() to check that
https://hg.python.org/cpython/rev/faf676d8c054
History
Date User Action Args
2016-02-11 11:38:28serhiy.storchakasetstatus: open -> closed
assignee: serhiy.storchaka
resolution: fixed
stage: patch review -> resolved
2016-02-11 11:12:45python-devsetnosy: + python-dev
messages: + msg260086
2016-02-10 21:56:09vstinnersetmessages: + msg260040
2016-02-10 11:13:40serhiy.storchakasetfiles: + test_support_check_no_resource_warning_2.patch

messages: + msg260005
2016-02-10 10:37:00martin.pantersetnosy: + martin.panter
messages: + msg260002
2016-02-10 10:26:21vstinnersetmessages: + msg260001
2016-02-10 10:15:17serhiy.storchakasetnosy: + vstinner
2016-02-10 10:14:02serhiy.storchakacreate