From b8a4691647a8850d681409c5dd35a12726cd94a1 Mon Sep 17 00:00:00 2001 From: Abdulaziz Aloqeely <52792999+Aloqeely@users.noreply.github.com> Date: Sat, 6 Apr 2024 02:11:11 +0300 Subject: [PATCH] No longer produce test.tar/test.zip after running test suite (#58168) Use temp path for test Co-authored-by: Abdulaziz Aloqeely <52792999+DAzVise@users.noreply.github.com> --- pandas/tests/frame/methods/test_to_csv.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pandas/tests/frame/methods/test_to_csv.py b/pandas/tests/frame/methods/test_to_csv.py index f87fa4137d62d..66a35c6f486a4 100644 --- a/pandas/tests/frame/methods/test_to_csv.py +++ b/pandas/tests/frame/methods/test_to_csv.py @@ -1406,19 +1406,21 @@ def test_to_csv_categorical_and_interval(self): expected = tm.convert_rows_list_to_csv_str(expected_rows) assert result == expected - def test_to_csv_warn_when_zip_tar_and_append_mode(self): + def test_to_csv_warn_when_zip_tar_and_append_mode(self, tmp_path): # GH57875 df = DataFrame({"a": [1, 2, 3]}) msg = ( "zip and tar do not support mode 'a' properly. This combination will " "result in multiple files with same name being added to the archive" ) + zip_path = tmp_path / "test.zip" + tar_path = tmp_path / "test.tar" with tm.assert_produces_warning( RuntimeWarning, match=msg, raise_on_extra_warnings=False ): - df.to_csv("test.zip", mode="a") + df.to_csv(zip_path, mode="a") with tm.assert_produces_warning( RuntimeWarning, match=msg, raise_on_extra_warnings=False ): - df.to_csv("test.tar", mode="a") + df.to_csv(tar_path, mode="a")