Skip to content

BUG: IO unit test creates file at home directory #40091

Closed
@chrispe

Description

@chrispe
  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of pandas.
  • (optional) I have confirmed this bug exists on the master branch of pandas.

The unit test at pandas/tests/io/test_common.py produces a file using a hardcoded name as shown below:

filename = path_type("~/sometest")
with icom.get_handle(filename, "w") as handles:
  assert os.path.isabs(handles.handle.name)
  assert os.path.expanduser(filename) == handles.handle.name

Problem description

A developer may encounter an empty file "sometest" appearing in their home directory (after running pytest). If the developer is unaware of that, then it may raise some wrong security concerns on their side. Also, in the extreme scenario that the developer has a file at the exact same path, then its content may be replaced.

Expected Output

I would expect the file produced by the unit test to be temporary and get deleted afterwards. Also, that the filename is generated rather than hardcoded.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIO DataIO issues that don't fit into a more specific labelTestingpandas testing functions or related to the test suite

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions