-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Expand file tree
/
Copy pathtest_fruit.py
More file actions
41 lines (32 loc) · 1.07 KB
/
test_fruit.py
File metadata and controls
41 lines (32 loc) · 1.07 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
30
31
32
33
34
35
36
37
38
39
40
41
import unittest
from fruit import capitalize_fruit_names
class TestFruit(unittest.TestCase):
def test_empty_list(self):
"""with empty list"""
self.assertEqual(capitalize_fruit_names([]), [])
def test_lowercase(self):
"""with lowercase strings"""
self.assertEqual(
capitalize_fruit_names(["apple", "banana", "cherry"]),
["Apple", "Banana", "Cherry"],
)
def test_uppercase(self):
"""with uppercase strings"""
self.assertEqual(
capitalize_fruit_names(["APPLE", "BANANA", "CHERRY"]),
["Apple", "Banana", "Cherry"],
)
def test_mixed_case(self):
"""with mixed case strings"""
self.assertEqual(
capitalize_fruit_names(["mAnGo", "grApE"]),
["Mango", "Grape"],
)
def test_non_string_element(self):
"""with a mix of integer and string elements"""
self.assertEqual(
capitalize_fruit_names([123, "banana"]),
["", "Banana"],
)
if __name__ == "__main__":
unittest.main()