Define a nose test class 'TestingCircleCreation' which tests the behavior of 'init' method with below specified four tests.
Define a nose test method 'test_creating_circle_with_numeric_radius', which creates a circle with radius 2.5 and check if it's radius matches to value 2.5
Define a nose test method 'test_creating_circle_with_negative_radius', which checks if ValueError exception is raised with the error message "radius must be between 0 and 1000 inclusive", while creating circle of radius -2.5 .
3.Define a nose test method 'test_creating_circle_with_greaterthan_radius', which checks if ValueError exception is raised with the error message "radius must be between 0 and 1000 inclusive" , while creating circle of radius 1000.1
- Define a nose test method 'test_creating_circle_with_nonnumeric_radius', which checks if TypeError exception is raised with the error message "radius must be a number", while creating circle of radius 'hello' .
i am not getting the expected output. Please suggest
Code used:
class TestCircleCreation(unittest.TestCase):
def test_creating_circle_with_numeric_radius(self):
c1=Circle(2.5)
self.assert_equal(c1.radius,2.5)
def test_creating_circle_with_negative_radius(self):
c1=Circle(2.5)
self.assert_equal(c1.radius,2.5)
self.assert_raises(ValueError, Circle, -2.5)
def test_creating_circle_with_greaterthan_radius(self):
c1=Circle(2.5)
self.assert_equal(c1.radius,2.5)
self.assert_raises(ValueError, Circle, 1000.1)
def test_creating_circle_with_nonnumeric_radius(self):
c1=Circle(2.5)
self.assert_equal(c1.radius,2.5)
self.assert_raises(TypeError, Circle, 'hello')