-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
Use tempfile for creating a file in home directory for a IO test #40122
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
Conversation
chrispe
commented
Feb 28, 2021
- closes BUG: IO unit test creates file at home directory #40091
- tests added / passed
- Ensure all linting tests pass, see here for how to run them
- whatsnew entry
pandas/tests/io/test_common.py
Outdated
with icom.get_handle(filename, "w") as handles: | ||
assert os.path.isabs(handles.handle.name) | ||
assert os.path.expanduser(filename) == handles.handle.name | ||
with tempfile.NamedTemporaryFile(dir=os.path.expanduser("~/")) as tmp: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use tm.ensure_clean
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, but current implementation of tm.ensure_clean
doesn't support custom directories (which is needed in this test case). Should we then first extend that function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok i guess this is fine. can you use pathlib.Path instead
pandas/tests/io/test_common.py
Outdated
with icom.get_handle(filename, "w") as handles: | ||
assert os.path.isabs(handles.handle.name) | ||
assert os.path.expanduser(filename) == handles.handle.name | ||
with tempfile.NamedTemporaryFile(dir=os.path.expanduser("~/")) as tmp: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok i guess this is fine. can you use pathlib.Path instead
Since we want to test for hardcoded case of "~", we should not use the Path.home()
lgtm ping on greenish (there is a failing numpy_dev build ATM) |
thanks @chrispe very nice! |