make sure citations file closed after read - #1620
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #1620 +/- ##
===========================================
- Coverage 97.99% 97.99% -0.01%
===========================================
Files 328 327 -1
Lines 18676 18666 -10
===========================================
- Hits 18301 18291 -10
Misses 375 375
Continue to review full report at Codecov.
|
brosaplanella
left a comment
There was a problem hiding this comment.
Looks good, thanks @chuckliu1979! Before merging, can you add a line to CHANGELOG under the bug fixes section explaining what you did?
|
@all-contributors please add @chuckliu1979 for bug report and code |
|
I've put up a pull request to add @chuckliu1979! 🎉 |
sure. new commit added |
Description
citations file not closed in pybamm.citations.Citations.read_citations which causes pytest failed if import pybamm:
_pytest/unraisableexception.py:78: in unraisable_exception_runtest_hook
warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))
E pytest.PytestUnraisableExceptionWarning: Exception ignored in: <_io.FileIO [closed]>
E
E Traceback (most recent call last):
E File "pybamm/citations.py", line 45, in read_citations
E for line in open(citations_file):
E ResourceWarning: unclosed file <_io.TextIOWrapper name='pybamm/CITATIONS.txt' mode='r' encoding='UTF-8'>
Fixes # (issue)
Type of change
Please add a line in the relevant section of CHANGELOG.md to document the change (include PR #) - note reverse order of PR #s. If necessary, also add to the list of breaking changes.
Key checklist:
$ flake8$ python run-tests.py --unit$ cd docsand then$ make clean; make htmlYou can run all three at once, using
$ python run-tests.py --quick.Further checks: