def test_diameter_and_area_change_based_on_radius(self): circle = Circle(2) self.assertEqual(circle.diameter, 4) circle.radius = 3 self.assertEqual(circle.diameter, 6) self.assertEqual(circle.area, math.pi * 9)
def test_no_negative_radius(self): circle = Circle(2) with self.assertRaises(ValueError) as context: circle.radius = -10 self.assertEqual(str(context.exception), "Radius cannot be negative")
def test_string_representation(self): circle = Circle(2) self.assertEqual(str(circle), 'Circle(2)') self.assertEqual(repr(circle), 'Circle(2)') circle.radius = 1 self.assertEqual(repr(circle), 'Circle(1)')