-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_utility.py
52 lines (42 loc) · 1.93 KB
/
test_utility.py
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import unittest
from utility import Utility
class TestUtility(unittest.TestCase):
def setUp(self):
pass
def tearDown(self):
pass
def test_clean_text(self):
text = "\nThis is awesome!!! On 21st we have a party \t\t We should enjoy it. "
actual = Utility.clean_text(text)
self.assertTrue(isinstance(actual, str))
self.assertEqual(actual, 'this is awesome on 21st we have a party we should enjoy it')
def test_lowercase(self):
text = "Today we'll have a good weather"
actual = Utility.lowercase(text)
self.assertTrue(isinstance(actual, str))
self.assertEqual(actual, "today we'll have a good weather")
def test_remove_newlines(self):
text = "\n\nThis is a sample text."
actual = Utility.remove_newlines(text)
self.assertTrue(isinstance(actual, str))
self.assertEqual(actual.strip(), "This is a sample text.")
def test_remove_tabs(self):
text = "\tThis is a sample text."
actual = Utility.remove_tabs(text)
self.assertTrue(isinstance(actual, str))
self.assertEqual(actual.strip(), "This is a sample text.")
def test_remove_multiple_whitespaces(self):
text = "Hello where are you ?"
actual = Utility.remove_multiple_whitespaces(text)
self.assertTrue(isinstance(actual, str))
self.assertEqual(actual.strip(), "Hello where are you ?")
def test_remove_trailing_whitespaces(self):
text = " This a sentence with trailing white spaces. "
actual = Utility.remove_trailing_whitespaces(text)
self.assertTrue(isinstance(actual, str))
self.assertEqual(actual.strip(), "This a sentence with trailing white spaces.")
def test_remove_special_chars(self):
text = "Help me!!!"
actual = Utility.replace_special_chars(text)
self.assertTrue(isinstance(actual, str))
self.assertEqual(actual.strip(), "Help me")