Skip to content

Two tests didn't properly assert an exception was raised. Fixed. #21409

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions pandas/tests/indexes/datetimes/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,6 @@ def test_get_indexer(self):
def test_reasonable_keyerror(self):
# GH#1062
index = DatetimeIndex(['1/3/2000'])
try:
with pytest.raises(KeyError) as excinfo:
index.get_loc('1/1/2000')
except KeyError as e:
assert '2000' in str(e)
assert '2000' in str(excinfo.value)
22 changes: 10 additions & 12 deletions pandas/tests/io/parser/c_parser_only.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,19 @@

class CParserTests(object):

def test_buffer_overflow(self):
@pytest.mark.parametrize(
'malf',
['1\r1\r1\r 1\r 1\r',
'1\r1\r1\r 1\r 1\r11\r',
'1\r1\r1\r 1\r 1\r11\r1\r'],
ids=['words pointer', 'stream pointer', 'lines pointer'])
def test_buffer_overflow(self, malf):
# see gh-9205: test certain malformed input files that cause
# buffer overflows in tokenizer.c

malfw = "1\r1\r1\r 1\r 1\r" # buffer overflow in words pointer
malfs = "1\r1\r1\r 1\r 1\r11\r" # buffer overflow in stream pointer
malfl = "1\r1\r1\r 1\r 1\r11\r1\r" # buffer overflow in lines pointer

cperr = 'Buffer overflow caught - possible malformed input file.'

for malf in (malfw, malfs, malfl):
try:
self.read_table(StringIO(malf))
except Exception as err:
assert cperr in str(err)
with pytest.raises(pd.errors.ParserError) as excinfo:
self.read_table(StringIO(malf))
assert cperr in str(excinfo.value)

def test_buffer_rd_bytes(self):
# see gh-12098: src->buffer in the C parser can be freed twice leading
Expand Down