Skip to content

Commit b8a4691

Browse files
authored
No longer produce test.tar/test.zip after running test suite (#58168)
Use temp path for test Co-authored-by: Abdulaziz Aloqeely <[email protected]>
1 parent cf1be37 commit b8a4691

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

pandas/tests/frame/methods/test_to_csv.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -1406,19 +1406,21 @@ def test_to_csv_categorical_and_interval(self):
14061406
expected = tm.convert_rows_list_to_csv_str(expected_rows)
14071407
assert result == expected
14081408

1409-
def test_to_csv_warn_when_zip_tar_and_append_mode(self):
1409+
def test_to_csv_warn_when_zip_tar_and_append_mode(self, tmp_path):
14101410
# GH57875
14111411
df = DataFrame({"a": [1, 2, 3]})
14121412
msg = (
14131413
"zip and tar do not support mode 'a' properly. This combination will "
14141414
"result in multiple files with same name being added to the archive"
14151415
)
1416+
zip_path = tmp_path / "test.zip"
1417+
tar_path = tmp_path / "test.tar"
14161418
with tm.assert_produces_warning(
14171419
RuntimeWarning, match=msg, raise_on_extra_warnings=False
14181420
):
1419-
df.to_csv("test.zip", mode="a")
1421+
df.to_csv(zip_path, mode="a")
14201422

14211423
with tm.assert_produces_warning(
14221424
RuntimeWarning, match=msg, raise_on_extra_warnings=False
14231425
):
1424-
df.to_csv("test.tar", mode="a")
1426+
df.to_csv(tar_path, mode="a")

0 commit comments

Comments
 (0)