Skip to content

Commit 2eee5e2

Browse files
committed
fix test
1 parent d77d290 commit 2eee5e2

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

pandas/tests/io/parser/test_compression.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ def parser_and_data(all_parsers, csv1):
3434
return parser, data, expected
3535

3636

37+
@pytest.fixture
38+
def empty_zip_file(tmp_path):
39+
# Create an empty zip file for testing
40+
zip_path = tmp_path / "empty.zip"
41+
with zipfile.ZipFile(zip_path, "w"):
42+
pass
43+
return zip_path
44+
45+
3746
@pytest.mark.parametrize("compression", ["zip", "infer", "zip2"])
3847
def test_zip(parser_and_data, compression):
3948
parser, data, expected = parser_and_data
@@ -158,14 +167,14 @@ def test_compression_utf_encoding(all_parsers, csv_dir_path, utf_value, encoding
158167

159168

160169
@pytest.mark.parametrize("invalid_compression", ["sfark", "bz3", "zipper"])
161-
def test_invalid_compression(all_parsers, invalid_compression):
170+
def test_invalid_compression(all_parsers, empty_zip_file, invalid_compression):
162171
parser = all_parsers
163172
compress_kwargs = {"compression": invalid_compression}
164173

165174
msg = f"Unrecognized compression type: {invalid_compression}"
166175

167176
with pytest.raises(ValueError, match=msg):
168-
parser.read_csv("test_file.zip", **compress_kwargs)
177+
parser.read_csv(empty_zip_file, **compress_kwargs)
169178

170179

171180
def test_compression_tar_archive(all_parsers, csv_dir_path):

pandas/tests/io/parser/test_unsupported.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -185,15 +185,10 @@ def test_close_file_handle_on_invalid_usecols(all_parsers):
185185
os.unlink(fname)
186186

187187

188-
def test_invalid_file_inputs(request, all_parsers):
188+
def test_invalid_file_inputs(all_parsers):
189189
# GH#45957
190190
parser = all_parsers
191-
if parser.engine == "python":
192-
request.applymarker(
193-
pytest.mark.xfail(reason=f"{parser.engine} engine supports lists.")
194-
)
195-
196-
with pytest.raises(ValueError, match="Invalid"):
191+
with pytest.raises(TypeError, match="Expected file path name or file-like"):
197192
parser.read_csv([])
198193

199194

0 commit comments

Comments
 (0)