background image

Use setUp() to create 

test fixture

import unittest

class StackTest(

unittest.TestCase

):

    # 

Create a new 

test fixture

 before each test

    def 

setUp

(self):

        self.capacity = 5
        self.stack = Stack(capacity)

    def 

test

_new_stack_is_empty

(self):

        self.assertTrue( self.

stack.isEmpty()

 )

        self.assertFalse( self.

stack.isFull()

 )

        self.assertEqual( 0, self.

stack.size()

 )

setUp() is called 

before each test

.

Comments:

Unit Testing in Python

navigate_before navigate_next