Skip to content

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