Skip to content

Commit

Permalink
No longer produce test.tar/test.zip after running test suite (#58168)
Browse files Browse the repository at this point in the history
Use temp path for test

Co-authored-by: Abdulaziz Aloqeely <52792999+DAzVise@users.noreply.github.com>
  • Loading branch information
Aloqeely and Aloqeely committed Apr 5, 2024
1 parent cf1be37 commit b8a4691
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pandas/tests/frame/methods/test_to_csv.py
Expand Up @@ -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")

0 comments on commit b8a4691

Please sign in to comment.