Skip to content

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

Merged
merged 11 commits into from
Mar 2, 2021

Conversation

chrispe
Copy link
Contributor

@chrispe chrispe commented Feb 28, 2021

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:
Copy link
Contributor

Choose a reason for hiding this comment

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

use tm.ensure_clean

Copy link
Contributor Author

@chrispe chrispe Feb 28, 2021

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?

Copy link
Contributor

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

@lithomas1 lithomas1 added the Testing pandas testing functions or related to the test suite label Feb 28, 2021
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:
Copy link
Contributor

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

@jreback jreback added this to the 1.3 milestone Mar 1, 2021
@jreback
Copy link
Contributor

jreback commented Mar 1, 2021

lgtm ping on greenish (there is a failing numpy_dev build ATM)

@jreback jreback merged commit 9ee5c1b into pandas-dev:master Mar 2, 2021
@jreback
Copy link
Contributor

jreback commented Mar 2, 2021

thanks @chrispe very nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: IO unit test creates file at home directory
3 participants