TST: --open-files did not catch ResourceWarning
See original GitHub issueIs this is not really an issue, feel free to close, as I am not familiar with the internals of open files check. Example log: https://travis-ci.org/astropy/astropy/jobs/442639768
It seems weird to me that --open-files
option still reported passing despite the presence of following warning:
sys:1: ResourceWarning: unclosed file <_io.BufferedWriter name=13>
cc @drdavella
Issue Analytics
- State:
- Created 5 years ago
- Comments:14 (14 by maintainers)
Top Results From Across the Web
Make pytest fail on ResourceWarning (unclosed files)
Try this: #test_example.py import pytest @pytest.mark.filterwarnings("error") def test_resourcewarning(): open('/dev/null').
Read more >test_multiprocessing_spawn ResourceWarning with -Werror
The question is why a resource warning is not emitted in normal case, with standard stdin. Proposed patch closes sys.
Read more >Changelog — pybedtools 0.9.0 documentation - GitHub Pages
Fixed a long-standing issue where streaming BedTool objects did not close their open file handles (stdout). When working with many (i.e. tens of...
Read more >[Django] #19905: ResourceWarning in formtools tests - Google Groups
2. We do think that open files provided to forms with file fields should be explicitly closed at some point in the code...
Read more >#19905 (ResourceWarning in formtools tests) – Django
We do think that open files provided to forms with file fields should be explicitly closed at some point in the code (and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Actually there is a way to show a traceback for ResourceWarning, with tracemalloc:
python3 -Wd -X tracemalloc=5
. From https://pythondev.readthedocs.io/debug_tools.html#resourcewarning, and thanks to @vstinner !IIRC, I think the problem is that many of them come from other libraries. If that’s the case, we would want to somehow filter to get only the ones that come from
astropy
, but I’m not sure there’s a straightforward way to do that in Python.That’s one of the reasons I haven’t really made any progress on implementing this functionality in
pytest-openfiles
, although it would still be really useful.