We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 556effc commit a3b9ee9Copy full SHA for a3b9ee9
pandas/tests/io/parser/compression.py
@@ -166,6 +166,21 @@ def test_read_csv_infer_compression(self):
166
167
inputs[3].close()
168
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
+
184
def test_invalid_compression(self):
185
msg = 'Unrecognized compression type: sfark'
186
with tm.assert_raises_regex(ValueError, msg):
0 commit comments