Skip to content

Commit

Permalink
Add invalid compression test
Browse files Browse the repository at this point in the history
  • Loading branch information
dhimmel committed Dec 12, 2016
1 parent 7940ab7 commit bf9fe97
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pandas/io/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,8 @@ def _read(filepath_or_buffer, kwds):

compression = kwds.get('compression')
if compression not in set(_compression_to_extension) | {None, 'infer'}:
raise ValueError('"{}" is not a valid compression'.format(compression))
msg = 'Unrecognized compression type: {}'.format(compression)
raise ValueError(msg)

if compression == 'infer':
compression = _infer_compression(filepath_or_buffer)
Expand Down
5 changes: 5 additions & 0 deletions pandas/io/tests/parser/compression.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,8 @@ def test_read_csv_infer_compression(self):
tm.assert_frame_equal(expected, df)

inputs[3].close()

def test_invalid_compression(self):
msg = 'Unrecognized compression type: sfark'
with tm.assertRaisesRegexp(ValueError, msg):
self.read_csv('test_file.zip', compression='sfark')

0 comments on commit bf9fe97

Please sign in to comment.