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

Remove ResourceWarnings from tests #123

Merged
merged 1 commit into from
Sep 5, 2024

Conversation

rtobar
Copy link
Contributor

@rtobar rtobar commented Sep 5, 2024

The open().read() calls were causing ResourceWarnings because the file was never explicitly closed, and are now replaced with a context managed open() call. In the case of the popens the reading from the stdout member had the same issue, so I'm replacing the stdout.read() + wait() with communicate() (which internally exhausts stdout and waits) + returncode.

All in all, this takes the warning count when running all tests from 45 down to 11, all of which are PytestUnraisableExceptionWarnings.

The open().read() calls were causing ResourceWarnings because the file
was never explicitly closed, and are now replaced with a context managed
open() call. In the case of the popens the reading from the stdout
member had the same issue, so I'm replacing the stdout.read() + wait()
with communicate() (which internally exhausts stdout and waits) +
returncode.

All in all, this takes the warning count when running all tests from 45
down to 11, all of which are PytestUnraisableExceptionWarnings.

Signed-off-by: Rodrigo Tobar <[email protected]>
@arigo
Copy link
Contributor

arigo commented Sep 5, 2024

LGTM, thanks!

@arigo arigo merged commit 88e67cc into python-cffi:main Sep 5, 2024
11 checks passed
@rtobar rtobar deleted the remove-resource-warnings branch September 5, 2024 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants