background image

Test for Exception

def test_sqrt_of_negative(self):

    

with self.assertRaises

(ValueError):

        

math.sqrt(-1)

assertRaises

 expects a block of code to raise an 

exception:

Comments:

Unit Testing in Python

navigate_before navigate_next