TST: replace ensure_clean with temp_file in pandas/tests/io/formats/t… #62977
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.
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:
temp_filefixture..zip,.gz, etc.), usedtemp_file.with_suffix(...).str(path)explicitly to preserve compatibility.Files changed:
Examples of edits:
temp_filefixture and writes/reads from it directly.temp_file.with_suffix("." + extension)for extension-specific files.temp_fileas 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:
pre-commit run --all-files
(All configured checks passed.)
Notes:
TST: Replace ensure_clean utility function with the temp_file pytest fixture TST: Replace
ensure_cleanutility function with thetemp_filepytest fixture #62435 (xref TST: Replaceensure_cleanutility function with thetemp_filepytest fixture #62435).Related:
xref: TST: Replace ensure_clean utility function with the temp_file pytest fixture TST: Replace
ensure_cleanutility function with thetemp_filepytest fixture #62435Related assist PR: TST: Assist Replace ensure_clean utility function with the temp_file pytest fixture #62435 #62461
closes TST: Replace
ensure_cleanutility function with thetemp_filepytest fixture #62435Tests added and passed if fixing a bug or adding a new feature
[√] All code checks passed.
Added type annotations to new arguments/methods/functions.
Added an entry in the latest
doc/source/whatsnew/vX.X.X.rstfile if fixing a bug or adding a new feature.