-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunit_test.py
More file actions
31 lines (23 loc) · 790 Bytes
/
Copy pathunit_test.py
File metadata and controls
31 lines (23 loc) · 790 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
import unittest
import capitalize
class TextPractice(unittest.TestCase):
def test_one_word(self):
text = 'python'
result = capitalize.cap(text)
self.assertEqual(result, "Python")
def test_multiple_word(self):
text = 'monty python'
result = capitalize.cap(text)
self.assertEqual(result, "Monty python")
def test_upper(self):
text = "python"
result = capitalize.upper(text)
self.assertEqual(result, "PYTHON")
def test_split(self):
s = 'hello world'
self.assertEqual(s.split(), ['hello', 'world'])
# check that s.split fails when the separator is not a string
with self.assertRaises(TypeError):
s.split(2)
if __name__ == '__main__':
unittest.main()