Skip to content

Commit

Permalink
Added unit test for splitdown function.
Browse files Browse the repository at this point in the history
All tests pass for py26, py27 and py36.
  • Loading branch information
John-Dennert committed Sep 6, 2017
1 parent 7aedf77 commit 07b69dc
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion petl/test/transform/test_regex.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


from petl.test.helpers import ieq, eq_
from petl.transform.regex import capture, split, search, searchcomplement
from petl.transform.regex import capture, split, search, searchcomplement, splitdown
from petl.transform.basics import TransformError


Expand Down Expand Up @@ -245,4 +245,35 @@ def test_search_unicode():
ieq(expect, actual)


def test_splitdown():

tbl = ((u'name', u'roles'),
(u'Jane Doe', u'president,engineer,tailor,lawyer'),
(u'John Doe', u'rocket scientist,optometrist,chef,knight,sailor'))

actual = splitdown(tbl, 'roles', ',')
expect = ((u'name', u'roles'),
(u'Jane Doe', u'president'),
(u'Jane Doe', u'engineer'),
(u'Jane Doe', u'tailor'),
(u'Jane Doe', u'lawyer'),
(u'John Doe', u'rocket scientist'),
(u'John Doe', u'optometrist'),
(u'John Doe', u'chef'),
(u'John Doe', u'knight'),
(u'John Doe', u'sailor'))

ieq(expect, actual)
ieq(expect, actual)
ieq(expect, actual)
ieq(expect, actual)
ieq(expect, actual)
ieq(expect, actual)
ieq(expect, actual)
ieq(expect, actual)
ieq(expect, actual)
ieq(expect, actual)


# TODO test sub()

0 comments on commit 07b69dc

Please sign in to comment.