Skip to content

Commit 9ff9109

Browse files
committed
TST: remove redundant invalid-path cases; assert TypeError for list (gh-62922)
1 parent 8ea1832 commit 9ff9109

File tree

1 file changed

+6
-28
lines changed

1 file changed

+6
-28
lines changed

pandas/tests/io/test_parquet.py

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -254,34 +254,12 @@ def test_read_parquet_invalid_path_types(tmp_path, engine):
254254
path = tmp_path / "test_read_parquet.parquet"
255255
df.to_parquet(path, engine=engine)
256256

257-
bad_path_types = [
258-
[str(path)], # list
259-
(str(path),), # tuple
260-
b"raw-bytes", # bytes
261-
]
262-
for bad in bad_path_types:
263-
match = (
264-
f"read_parquet expected str/os.PathLike or file-like object, "
265-
f"got {type(bad).__name__} type"
266-
)
267-
with pytest.raises(TypeError, match=match):
268-
read_parquet(bad, engine=engine)
269-
270-
271-
def test_read_parquet_valid_path_types(tmp_path, engine):
272-
# GH #62922
273-
df = pd.DataFrame({"a": [1]})
274-
path = tmp_path / "test_read_parquet.parquet"
275-
df.to_parquet(path, engine=engine)
276-
# str
277-
read_parquet(str(path), engine=engine)
278-
# os.PathLike
279-
read_parquet(pathlib.Path(path), engine=engine)
280-
# file-like object
281-
buf = BytesIO()
282-
df.to_parquet(buf, engine=engine)
283-
buf.seek(0)
284-
read_parquet(buf, engine=engine)
257+
msg = (
258+
f"read_parquet expected str/os.PathLike or file-like object, "
259+
f"got list type"
260+
)
261+
with pytest.raises(TypeError, match=msg):
262+
read_parquet([str(path)], engine=engine)
285263

286264

287265
def test_invalid_engine(df_compat, temp_file):

0 commit comments

Comments
 (0)