Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### December 2010 ###
- ### Question 2 ###
- import unittest
- from list_to_lower import list_to_lower, BadTypeException
- class TestListToLower(unittest.TestCase):
- def setUp(self):
- ''' Set up an empty list. '''
- self.my_list = []
- def tearDown(self):
- ''' Clean up.'''
- self.my_list = None
- def testListToLowerEmptyList(self):
- ''' Test list_to_lower on an empty list. '''
- assert list_to_lower(self.my_list) == []
- def testListToLowerTypicalList(self):
- ''' Test list_to_lower on a typical list of strings with mixed cases. '''
- self.my_list = ['Ab', 'aB', 'aabBb']
- assert list_to_lower(self.my_list) == ['ab', 'ab', 'aabbb']
- def testListToLowerBadTypes(self):
- ''' Test list_to_lower on a list that contains bad types (i.e. an int).
- '''
- self.my_list = ['a', 3]
- try:
- list_to_lower(self.my_list)
- except BadTypeException, error:
- assert error.message == 'Non-string object found.'
- except:
- assert False
- if __name__ == '__main__':
- suite = unittest.TestLoader().loadTestsFromTestCase(TestListToLower)
- unittest.TextTestRunner(verbosity=2).run(suite)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement