Skip to content

Commit a3b9ee9

Browse files
committed
Test: infer compression from pathlib.Path
1 parent 556effc commit a3b9ee9

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

pandas/tests/io/parser/compression.py

+15
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,21 @@ def test_read_csv_infer_compression(self):
166166

167167
inputs[3].close()
168168

169+
def test_read_csv_infer_compression_pathlib(self):
170+
"""
171+
Test that compression is inferred from pathlib.Path paths.
172+
"""
173+
try:
174+
import pathlib
175+
except ImportError:
176+
pytest.skip('need pathlib to run')
177+
expected = self.read_csv(self.csv1, index_col=0, parse_dates=True)
178+
for extension in '', '.gz', '.bz2':
179+
path = pathlib.Path(self.csv1 + extension)
180+
df = self.read_csv(
181+
path, index_col=0, parse_dates=True, compression='infer')
182+
tm.assert_frame_equal(expected, df)
183+
169184
def test_invalid_compression(self):
170185
msg = 'Unrecognized compression type: sfark'
171186
with tm.assert_raises_regex(ValueError, msg):

0 commit comments

Comments
 (0)