#--------- # Filename: format_driver.py # Author: Ric Heishman # Lecture/Lab section: 00x/2xx # Assignment: Lab #5 # Date: 09/21/07 # Description: This driver file tests for the proper operation # of the Format.py library functions. # Discrepancies: None #--------- #--------- # imported modules/libraries #--------- import Format, sys #--------- # function definitions #--------- #--------- # main #--------- def main(): sys.path.insert(0,"/Users/rheishma/GMU/Classes/" \ "CS-112/Examples/Week-5") # #Test *format_as_currency* function # print "Testing *format_as_currency* function..." print #Test *string* input with all three justifications print "Testing *string* input with all three justifications\n" x = Format.format_as_currency("125.5",25) print "-" + x + "-" x = Format.format_as_currency("125.5",25,"left") print "-" + x + "-" x = Format.format_as_currency("125.5",25,"center") print "-" + x + "-" #Test *floating point* input with all three justifications print "\nTesting *floating point* input with all three justifications\n" x = Format.format_as_currency(125.5,25) print "-" + x + "-" x = Format.format_as_currency(125.5,25,"left") print "-" + x + "-" x = Format.format_as_currency(125.5,25,"center") print "-" + x + "-" #Test *integer* input with all three justifications print "\nTesting *integer* input with all three justifications\n" x = Format.format_as_currency(125,25) print "-" + x + "-" x = Format.format_as_currency(125,25,"left") print "-" + x + "-" x = Format.format_as_currency(125,25,"center") print "-" + x + "-" # #Test *format_total* function # print print "Testing *format_total* function..." print test_list = ["Materials", 238.5, \ "Software", 3145.8, \ "Travel", 214] x = Format.format_total(test_list) print x main()