Skip to content

Fix unclosed resource in validators #427

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

Merged
merged 5 commits into from
Jul 12, 2018

Conversation

ApamNapat
Copy link
Contributor

The resource used by urlopen was never explicitly closed, running an app with pythons -W all flag raised loads of ResourceWarnings. Using a context manager is a simple fix.

@Julian
Copy link
Member

Julian commented Jul 2, 2018

Thanks! Really appreciated.

Could you write a test to ensure this doesn't regress?

@ApamNapat
Copy link
Contributor Author

@Julian I fixed and extended an already existing test to check for context manager's calls. If there is still something lacking please let me know.

@Julian Julian merged commit 30bd2bc into python-jsonschema:master Jul 12, 2018
(resource_manager_mock.
__enter__.return_value.
read.return_value.
decode.return_value) = json.dumps(schema).encode("utf8")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look correct, and is a good example of why mocking is sadness :/

decode returns unicode, not bytes.

Will fix on merge though, thanks.

@Julian
Copy link
Member

Julian commented Jul 12, 2018

Merged, thanks!

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