-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_transform_util.py
More file actions
29 lines (22 loc) · 1.02 KB
/
test_transform_util.py
File metadata and controls
29 lines (22 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from nose.tools import assert_equal
from ..transform_util import TransformUtil
class TestTransformUtil():
states = [' Alabama ', 'Georgia!', 'Georgia', 'georgia', \
'FlOrIda', 'south carolina##', 'West virginia?']
expected_output = ['Alabama',
'Georgia',
'Georgia',
'Georgia',
'Florida',
'South Carolina',
'West Virginia']
def test_remove_punctuation(self):
assert_equal(TransformUtil.remove_punctuation('!#?'), '')
def test_map_remove_punctuation(self):
# Map applies a function to a collection
output = map(TransformUtil.remove_punctuation, self.states)
assert_equal('!#?' not in output, True)
def test_clean_strings(self):
clean_ops = [str.strip, TransformUtil.remove_punctuation, str.title]
output = TransformUtil.clean_strings(self.states, clean_ops)
assert_equal(output, self.expected_output)