Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix tests that fail to close files that they open #1435

Closed
ctb opened this issue Apr 3, 2021 · 2 comments · Fixed by #1550
Closed

fix tests that fail to close files that they open #1435

ctb opened this issue Apr 3, 2021 · 2 comments · Fixed by #1550
Labels
good next issue An issue that should be ready to resolve. python Pull requests that update Python code testing

Comments

@ctb
Copy link
Contributor

ctb commented Apr 3, 2021

There are several tests in test_lca.py that are causing warnings during the tests, because I did a bad thing and opened files without closing them.

The three tests are:

test_single_summarize_to_output
test_single_classify_to_output
test_single_classify_to_output_no_name

and they all use some variant of this code,

outdata = open(os.path.join(location, 'outfile.txt'), 'rt').read()

which doesn't close the file. This results in a warning when py.test runs the tests.

The proper usage is something like

with open(...) as fp:
   outdata = fp.read()

which will use a context manager to close the file after the with block.

Fix!

@ctb ctb added python Pull requests that update Python code testing good next issue An issue that should be ready to resolve. labels Apr 3, 2021
@ctb ctb changed the title fix test that fail to close files that they open fix tests that fail to close files that they open Apr 3, 2021
@keyabarve
Copy link
Contributor

Can I try to fix this? @ctb

@ctb
Copy link
Contributor Author

ctb commented May 5, 2021

sure!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good next issue An issue that should be ready to resolve. python Pull requests that update Python code testing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants