Skip to content

Commit

Permalink
Test: infer compression from pathlib.Path
Browse files Browse the repository at this point in the history
  • Loading branch information
dhimmel committed Aug 9, 2017
1 parent 556effc commit a3b9ee9
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pandas/tests/io/parser/compression.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,21 @@ def test_read_csv_infer_compression(self):

inputs[3].close()

def test_read_csv_infer_compression_pathlib(self):
"""
Test that compression is inferred from pathlib.Path paths.
"""
try:
import pathlib
except ImportError:
pytest.skip('need pathlib to run')
expected = self.read_csv(self.csv1, index_col=0, parse_dates=True)
for extension in '', '.gz', '.bz2':
path = pathlib.Path(self.csv1 + extension)
df = self.read_csv(
path, index_col=0, parse_dates=True, compression='infer')
tm.assert_frame_equal(expected, df)

def test_invalid_compression(self):
msg = 'Unrecognized compression type: sfark'
with tm.assert_raises_regex(ValueError, msg):
Expand Down

0 comments on commit a3b9ee9

Please sign in to comment.