def test_rand(self): from random import randint for i in range(100): ca = Point(randint(-50, 50), randint(-50, 50)) ra = randint(0, 50) a = Circle(ca, ra) actual = circle_area(a) expected = 3.141592653589793 * ra**2 self.assertEqual(round(actual, 6), round(expected, 6))
def test_types(self): # handle type errors with pytest.raises(TypeError): circle_area(3 + 5j) with pytest.raises(TypeError): circle_area(True) with pytest.raises(TypeError): circle_area("cat")
def test_area(self): #Test areas when radius >=0 self.assertAlmostEqual(circle_area(1),pi) self.assertAlmostEqual(circle_area(0),0) self.assertAlmostEqual(circle_area(2.1),pi*2.1**2)
def test_area(self): #testing for radius >=0 self.assertAlmostEqual(circle_area(1), pi) self.assertAlmostEqual(circle_area(0), 0) self.assertAlmostEqual(circle_area(7.6), pi*(7.6**2))
def test_area(self): '''Testing area when radius >= 0''' self.assertAlmostEqual(circle_area(1), pi) self.assertAlmostEqual(circle_area(0), 0) self.assertAlmostEqual(circle_area(3.3), pi * 3.3 * 3.3)
def test(self): self.assertEqual(round(circle_area(Circle(Point(10, 10), 30)), 6), 2827.433388) self.assertEqual(round(circle_area(Circle(Point(25, -70), 30)), 6), 2827.433388) self.assertEqual(round(circle_area(Circle(Point(-15, 5), 0)), 6), 0) self.assertEqual(round(circle_area(Circle(Point(-15, 5), 12.5)), 6), 490.873852)
def test_circle_area(): assert round(circle_area(Circle(Point(10, 10), 30)), 6) == 2827.433388 assert round(circle_area(Circle(Point(25, -70), 30)), 6) == 2827.433388 assert round(circle_area(Circle(Point(-15, 5), 0)), 6) == 0 assert round(circle_area(Circle(Point(-15, 5), 12.5)), 6) == 490.873852
def test_circle_area(self): self.assertEqual(78.55, circle_area(5)) self.assertEqual(28.278, circle_area(3))
def test_area(self): # test areas when radius >= 0 assert circle_area(1) == math.pi assert circle_area(0) == 0 assert circle_area(2.1) == math.pi * 2.1**2
def test_values(self): # raise value error when radius is negative with pytest.raises(ValueError): circle_area(-2)