Skip to content

Conversation

@IngramBJ
Copy link
Contributor

@IngramBJ IngramBJ commented Nov 4, 2025

TST: replace ensure_clean with temp_file in pandas/tests/io/formats/test_to_csv.py (xref #62435)

What:
Replace tm.ensure_clean usage with the pytest temp_file fixture (and tmp_path where a specific extension was required) in
pandas/tests/io/formats/test_to_csv.py.

Why:
The project standard is to use the temp_file pytest fixture instead of the legacy ensure_clean helper. This PR is a small, focused change toward the larger effort tracked in issue #62435.

Changes:

  • Replaced usages of ensure_clean / tm.ensure_clean with the pytest temp_file fixture.
  • Where tests required a specific file extension (e.g. .zip, .gz, etc.), used temp_file.with_suffix(...).
  • Where downstream APIs required a string path, used str(path) explicitly to preserve compatibility.
  • No functional test logic changes; only temporary-file helper replacement.

Files changed:

  • pandas/tests/io/formats/test_to_csv.py

Examples of edits:

  • test_to_csv_with_single_column: now accepts temp_file fixture and writes/reads from it directly.
  • compression tests: use temp_file.with_suffix("." + extension) for extension-specific files.
  • binary-handle tests: continue to open the temp_file as before but using the fixture-provided Path.

Local verification:
I ran the modified tests locally and verified the file and individual tests pass:

  • Run the whole file:
    pytest -q pandas/tests/io/formats/test_to_csv.py
    (All tests in the file passed locally.)

  • Run an individual test:
    pytest -q pandas/tests/io/formats/test_to_csv.py::TestToCSV::test_to_csv_with_single_column
    (This test passed locally.)

Pre-commit hooks:

  • Ran pre-commit locally:
    pre-commit run --all-files
    (All configured checks passed.)

Notes:

Related:

to_compression = "infer" if to_infer else compression
read_compression = "infer" if read_infer else compression

path_ext = str(temp_file) + "." + compression_to_extension[compression]
Copy link
Member

Choose a reason for hiding this comment

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

i dont think this change is necessary. also it doesnt match the PR title description

@jbrockmendel
Copy link
Member

This looks AI-generated, which we discourage.

@jbrockmendel jbrockmendel added the AI Slop Suspected of being AI-generated, which is not welcome. label Nov 4, 2025
@IngramBJ IngramBJ marked this pull request as draft November 4, 2025 16:58
@IngramBJ IngramBJ closed this Nov 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI Slop Suspected of being AI-generated, which is not welcome.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TST: Replace ensure_clean utility function with the temp_file pytest fixture

2 participants