background image

Use tearDown() to clean up after tests

class FileTest(

unittest.TestCase

):

    def 

setUp

(self):

        

# open file containing test data

        self.file = open("testdata", "r")

    def 

tearDown

(self):

        self.file.close()

tearDown() is called 

after each test

.  Its not usually 

needed, since setUp will re-initialize test fixture.

Comments:

Unit Testing in Python

navigate_before