Skip to content

Commit ec0a292

Browse files
committed
Test: infer compression from pathlib.Path
1 parent 924b433 commit ec0a292

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
@@ -157,6 +157,21 @@ def test_read_csv_infer_compression(self):
157157

158158
inputs[3].close()
159159

160+
def test_read_csv_infer_compression_pathlib(self):
161+
"""
162+
Test that compression is inferred from pathlib.Path paths.
163+
"""
164+
try:
165+
import pathlib
166+
except ImportError:
167+
pytest.skip('need pathlib to run')
168+
expected = self.read_csv(self.csv1, index_col=0, parse_dates=True)
169+
for extension in '', '.gz', '.bz2':
170+
path = pathlib.Path(self.csv1 + extension)
171+
df = self.read_csv(
172+
path, index_col=0, parse_dates=True, compression='infer')
173+
tm.assert_frame_equal(expected, df)
174+
160175
def test_invalid_compression(self):
161176
msg = 'Unrecognized compression type: sfark'
162177
with tm.assert_raises_regex(ValueError, msg):

0 commit comments

Comments
 (0)