background image

Write the Tests

File: 

test_average.py

import unittest

from listutil import average

class TestAverage(unittest.TestCase):

    def test_average_singleton_list(self):

self.assertEqual( 5, average([5]) )

  def test_list_with_many_values(self):

       

# test average of many values

    def test_average_of_empty_list(self):

       

# test that average([]) throws exception

10 minutes

Comments:

Unit Testing in Python

navigate_before navigate_next