Skip to content

Commit

Permalink
Requested changes made
Browse files Browse the repository at this point in the history
  • Loading branch information
MPKenley committed Jan 12, 2025
1 parent 4f2eb90 commit 6306d36
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
10 changes: 10 additions & 0 deletions solutions/challenge_23/celsius_to_fahrenheit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")

Expand Down
12 changes: 6 additions & 6 deletions solutions/tests/challenge_23/test_celsius_to_fahrenheit.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,32 @@


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])

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."""
with self.assertRaises(ValueError):
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])

0 comments on commit 6306d36

Please sign in to comment.