Replace mock_open with temporary file#63
Merged
mikss merged 2 commits intoio_format_storage_viewfrom Jul 21, 2021
Merged
Conversation
mikss
approved these changes
Jul 21, 2021
Contributor
mikss
left a comment
There was a problem hiding this comment.
I don't fully grasp the rules of thumb for when to use mock_open versus temporary files (or, whether mock_open is ever preferable), but this looks good to me.
Member
Author
|
I'm not a bit fan of patching/mocking generally (too easily coupled to drifting implementations), so I tend to use temp files more often (though |
JacobHayes
added a commit
that referenced
this pull request
Jul 21, 2021
* Add NamedTemporaryFile alternative that can be re-opened on Windows * Use NamedTemporaryFile rather than mock_open (to fix breakpoint)
mikss
added a commit
that referenced
this pull request
Jul 21, 2021
* python view initial pass * tests for views * type fiddling * remove validate method * change multimethod to multidispatch * Replace mock_open with temporary file (#63) * Add NamedTemporaryFile alternative that can be re-opened on Windows * Use NamedTemporaryFile rather than mock_open (to fix breakpoint) * re-order format/storage/view, and move tests * Remove LocalFile.path default * Check before writing empty data Co-authored-by: Jacob Hayes <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When debugging a few pydantic issues in #62, adding a breakpoint before https://github.com/replicahq/artigraph/blob/556c7505fa573b81889632b50644c546fbf0c49d/src/arti/views/core.py#L28 while within https://github.com/replicahq/artigraph/blob/556c7505fa573b81889632b50644c546fbf0c49d/tests/arti/views/test_views.py#L24 would fail with a cryptic error. Traced it down to a file (stdin?) opened by
pdbreturning the pickled binary data, rather than the text it expected.I tried to swap
mock_openwithNamedTemporaryFile, but that doesn't support re-opening the file on Windows. Instead, I added anamed_temporary_filehelper that usesNamedTemporaryDirectoryunder the hood instead for better portability.