diff --git a/drone_test/__init__.py b/drone_test/__init__.py new file mode 100644 index 0000000..936bd02 --- /dev/null +++ b/drone_test/__init__.py @@ -0,0 +1,12 @@ +"""Python module to test drone builds""" + +import math + +def circle_area(radius: float): + """Calculate the area of a circle + + :param radius: circle radius + :raises ValueError: radius is negative + :return: area of the circle + """ + return math.pi * radius ** 2 diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_circle_area.py b/tests/test_circle_area.py new file mode 100644 index 0000000..d0f8d56 --- /dev/null +++ b/tests/test_circle_area.py @@ -0,0 +1,15 @@ +from unittest import TestCase +import math + +from drone_test import circle_area + +class CircleAreaTest(TestCase): + def test_area_1(self): + self.assertEqual(circle_area(1), math.pi) + + def test_area_2(self): + self.assertEqual(circle_area(2), math.pi * 4) + + def test_negative(self): + with self.assertRaises(ValueError): + circle_area(-1)