-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata_cleaning_test.py
More file actions
37 lines (32 loc) · 824 Bytes
/
data_cleaning_test.py
File metadata and controls
37 lines (32 loc) · 824 Bytes
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
30
31
32
33
34
35
36
37
import pytest
from data_cleaning import strip_html, strip_parens, extract_word
@pytest.mark.parametrize(
"raw,expected",
[
('hello <b>world</b>', 'hello world'),
('thing <img src="abc">', 'thing'),
('hello<br>world', 'hello world'),
('hello<br/>world', 'hello world'),
('hello<div>world</div>', 'hello world')
]
)
def test_strip_html(raw, expected):
assert strip_html(raw) == expected
@pytest.mark.parametrize(
"raw,expected",
[
('hello (world)', 'hello'),
('(hello) world', 'world'),
]
)
def test_strip_parens(raw, expected):
assert strip_parens(raw) == expected
@pytest.mark.parametrize(
"raw,expected",
[
('<b>hello<b/> (world)', 'hello'),
('(hello)\n\nworld', 'world'),
]
)
def test_extract_word(raw, expected):
assert extract_word(raw) == expected