Skip to content

Commit

Permalink
Merge pull request #516 from onyxfish/368
Browse files Browse the repository at this point in the history
Add failing test demonstrating #368
  • Loading branch information
James McKinney committed Jan 23, 2016
2 parents 5637817 + ad99262 commit 512dd38
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion csvkit/grep.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,5 @@ def __init__(self, pattern):
self.pattern = pattern

def __call__(self, arg):
return self.pattern.match(arg)
return self.pattern.search(arg)

14 changes: 14 additions & 0 deletions tests/test_grep.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,17 @@ def test_any_match_and_inverse(self):
self.fail("Should be no more rows left.")
except StopIteration:
pass

def test_multiline(self):
table = [
['a', 'b'],
['1', 'foo\nbar']
]
fcr = FilteringCSVReader(iter(table), patterns={'b': re.compile('bar')})
self.assertEqual(table[0], next(fcr))
self.assertEqual(table[1], next(fcr))
try:
next(fcr)
self.fail("Should be no more rows left.")
except StopIteration:
pass

0 comments on commit 512dd38

Please sign in to comment.