Skip to content

Commit

Permalink
Added tests for multiply function and fixed linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
NimahMasuud committed Jan 11, 2025
1 parent f6cd89e commit cc08f31
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ venv/
*.idea
*.ruff_cache

.codegpt
.codegpt
12 changes: 9 additions & 3 deletions solutions/multiply.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
#!/usr/bin/env python3
# -- coding: utf-8 --
"""
This module contains unit tests for the `multiply` function in `multiply.py`.
The tests cover various scenarios including valid inputs, defensive assertions, and boundary cases.
"""


def multiply(a: float, b: float) -> float:
"""
Multiplies two numbers and returns the result.
Args:
a (float): The first number to be multiplied.
a (float): The first number to be multiplied.
Must be a real number (no specific range constraints).
b (float): The second number to be multiplied.
b (float): The second number to be multiplied.
Must be a real number (no specific range constraints).
Returns:
Expand All @@ -28,5 +34,5 @@ def multiply(a: float, b: float) -> float:
raise TypeError("The first argument must be a number.")
if not isinstance(b, (int, float)):
raise TypeError("The second argument must be a number.")

return a * b
4 changes: 3 additions & 1 deletion solutions/tests/test_multiply.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"""

import unittest
from ..multiply import multiply
from solutions.multiply import multiply


class TestMultiplyFunction(unittest.TestCase):
"""Unit tests for the `multiply` function."""
Expand Down Expand Up @@ -43,5 +44,6 @@ def test_multiply_invalid_second_argument(self):
with self.assertRaises(TypeError):
multiply(3, None)


if __name__ == "__main__":
unittest.main()

0 comments on commit cc08f31

Please sign in to comment.