|
| 1 | +import unittest |
| 2 | +from fruit import capitalize_fruit_names |
| 3 | + |
| 4 | +class TestAllFruits(unittest.TestCase): |
| 5 | + def test_empty_list(self): |
| 6 | + """with empty list""" |
| 7 | + self.assertEqual(capitalize_fruit_names([]), []) |
| 8 | + |
| 9 | + def test_lowercase_list(self): |
| 10 | + """with lowercase strings""" |
| 11 | + self.assertEqual( |
| 12 | + capitalize_fruit_names(["apple", "banana", "cherry"]), |
| 13 | + ["Apple", "Banana", "Cherry"], |
| 14 | + ) |
| 15 | + |
| 16 | + def test_uppercase_list(self): |
| 17 | + """with uppercase strings""" |
| 18 | + self.assertEqual( |
| 19 | + capitalize_fruit_names(["APPLE", "BANANA", "CHERRY"]), |
| 20 | + ["Apple", "Banana", "Cherry"], |
| 21 | + ) |
| 22 | + |
| 23 | + def test_mixed_case_list(self): |
| 24 | + """with mixed case strings""" |
| 25 | + self.assertEqual( |
| 26 | + capitalize_fruit_names(["mAnGo", "grApE"]), ["Mango", "Grape"] |
| 27 | + ) |
| 28 | + |
| 29 | + def test_non_string_element(self): |
| 30 | + """with a mix of integer and string elements""" |
| 31 | + self.assertEqual( |
| 32 | + capitalize_fruit_names([123, "banana"]), ["", "Banana"] |
| 33 | + ) |
| 34 | + |
| 35 | +if __name__ == "__main__": |
| 36 | + unittest.main() |
0 commit comments