0% found this document useful (1 vote)
7K views1 page

Python Qualis - Hands On Nose

This document contains unit tests to test the creation and properties of Circle objects. It defines classes to test creating circles with valid and invalid radius values. It also defines classes to test the area and circumference calculation methods for circles with different radius values, including minimum, maximum, and random radii.

Uploaded by

AGDB
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
7K views1 page

Python Qualis - Hands On Nose

This document contains unit tests to test the creation and properties of Circle objects. It defines classes to test creating circles with valid and invalid radius values. It also defines classes to test the area and circumference calculation methods for circles with different radius values, including minimum, maximum, and random radii.

Uploaded by

AGDB
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

from proj.

circle import Circle


from nose.tools import assert_raises, eq_, eq_

class TestingCircleCreation:
def test_creating_circle_with_numeric_radius(self):
c1 = Circle(2.5)
eq_(2.5, c1.radius)

def test_creating_circle_with_negative_radius(self):
with assert_raises(ValueError) as e:
c = Circle(-2.5)
eq_(str(e.exception), 'radius must be between 0 and 1000 inclusive')

def test_creating_circle_with_greaterthan_radius(self):
with assert_raises(ValueError) as e:
c = Circle(1000.1)
eq_(str(e.exception), 'radius must be between 0 and 1000 inclusive')

def test_creating_circle_with_nonnumeric_radius(self):
with assert_raises(TypeError) as e:
c = Circle('hello')
eq_(str(e.exception), 'radius must be a number')

class TestCircleArea:
def test_circlearea_with_random_numeric_radius(self):
c1 = Circle(2.5)
eq_(c1.area(), 19.63)

def test_circlearea_with_min_radius(self):
# Define a circle 'c2' with radius 0, and check if
# its area is 0.
c2 = Circle(0)
eq_(c2.area(), 0)

def test_circlearea_with_max_radius(self):
c3 = Circle(1000)
eq_(c3.area(), 3141592.65)

class TestCircleCircumference:
def test_circlecircum_with_random_numeric_radius(self):
c1 = Circle(2.5)
eq_(c1.circumference(), 15.71)

def test_circlecircum_with_min_radius(self):
c2 = Circle(0)
eq_(0, c2.circumference())

def test_circlecircum_with_max_radius(self):
c3 = Circle(1000)
eq_(c3.circumference(), 6283.19)

You might also like