From 6306d3612eab7953608b1bd5e5a8a3406543f8e4 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 12 Jan 2025 09:06:01 -0500 Subject: [PATCH] Requested changes made --- solutions/challenge_23/celsius_to_fahrenheit.py | 10 ++++++++++ .../tests/challenge_23/test_celsius_to_fahrenheit.py | 12 ++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/solutions/challenge_23/celsius_to_fahrenheit.py b/solutions/challenge_23/celsius_to_fahrenheit.py index 4a7345466..2a674afc0 100644 --- a/solutions/challenge_23/celsius_to_fahrenheit.py +++ b/solutions/challenge_23/celsius_to_fahrenheit.py @@ -13,7 +13,17 @@ def celsius_to_fahrenheit(celsius_list): Raises: ValueError: If input is not a list or contains invalid elements. + + >>> celsius_to_fahrenheit([0, 100]) + [32.0, 212.0] + + >>> celsius_to_fahrenheit([-40, -10]) + [-40.0, 14.0] + + >>> celsius_to_fahrenheit([25.5, 0.5]) + [77.9, 32.9] """ + if not isinstance(celsius_list, list): raise ValueError("Input must be a list.") diff --git a/solutions/tests/challenge_23/test_celsius_to_fahrenheit.py b/solutions/tests/challenge_23/test_celsius_to_fahrenheit.py index 0c2dd3ff9..8097eb518 100644 --- a/solutions/tests/challenge_23/test_celsius_to_fahrenheit.py +++ b/solutions/tests/challenge_23/test_celsius_to_fahrenheit.py @@ -5,17 +5,18 @@ class TestCelsiusToFahrenheit(unittest.TestCase): - """Unit tests for the celsius_to_fahrenheit function.""" + """This tests module provide test for the celsius_to_fahrenheit function. + It tests the function with different inputs and checks if the output is as expected.""" - def test_positive_temperatures(self): + def test__with_positive_temperatures(self): """Test the program with positive temperature list.""" self.assertEqual(celsius_to_fahrenheit([0, 100]), [32.0, 212.0]) - def test_negative_temperatures(self): + def test_with_negative_temperatures(self): """Test the program with negative temperatures list.""" self.assertEqual(celsius_to_fahrenheit([-40, -10]), [-40.0, 14.0]) - def test_mixed_temperatures(self): + def test_with_mixed_temperatures(self): """Test the program with mixed temperatures list""" self.assertEqual(celsius_to_fahrenheit([-10, 0, 25]), [14.0, 32.0, 77.0]) @@ -23,7 +24,6 @@ def test_float_temperatures(self): """Test the program with float temperatures.""" result = celsius_to_fahrenheit([0.5, -0.5]) self.assertAlmostEqual(result[0], 32.9, places=1) - self.assertAlmostEqual(result[1], 31.1, places=1) def test_invalid_input_non_list(self): """Test invalid input that is not a list.""" @@ -31,6 +31,6 @@ def test_invalid_input_non_list(self): celsius_to_fahrenheit("not a list") def test_invalid_input_non_numeric_elements(self): - """Test invalid input that contains non-numeric elements.""" + """Test the program with invalid input that contains non-numeric elements.""" with self.assertRaises(ValueError): celsius_to_fahrenheit([30, "a string", 45])