from question2 import swapchars from question3 import sortcat from question4a import look_away # Runs tests and prints results if __name__ == '__main__': print "Displaying tests:" print "--- Question 2 ---" test_str = "There were a lot of escopeoples in the elevator on Tuesday." result_str = "Thyry wyry a lot of yseopyoplys in thy ylyvator on Tuysdae." print "Reversing: {}".format(test_str) print "Result: {}".format(swapchars(test_str)) print "Should be: {}".format(result_str) print "" print "Reversing: HeLlO" print "Result: {}".format(swapchars("HeLlO")) print "Should be: {}".format("HeOoL") print "" print "--- Question 3 ---" print "sortcat(1, 'abc', 'bc')" print "Gives: {}".format(sortcat(1, 'abc', 'bc')) print "Should be: {}".format('abc') print "" print "sortcat(2, 'bc', 'c', 'abc')" print "Gives: {}".format(sortcat(2, 'bc', 'c', 'abc')) print "Should be: {}".format('abcbc') print "" print "sortcat(-1, 'abc', 2)" print "Gives: {}".format(sortcat(-1, 'abc', 2)) print "Should be: {}".format("abc2") print ""
from question1 import fizzbuzz print "fizzbuzz: " print(fizzbuzz()) """For this we expect to see numbers divisible by 3 to say fizz, numbers divisble by 5 to say buzz, and numbers divisible by both to say fizzbuzz""" print #test for question2.py from question2 import swapchars print "swapchars: " print(swapchars("This is a long sentence with many spaces and characters")) print(swapchars("This.sentence.has.a.lot.of.punctuation")) print(swapchars("aaaaaa")) print(swapchars("this uses the intermediate character, ~~ when replacing")) """for the last one we expect the ~~ to be replaced when it shouldn't be because that is the intermediate character used for swapping. I could not think of a way around that. For the 2nd test the punctuation is most common character. I could have created a string devoid off all punctuation and spaces, but that seemed tedious and unnecessary for the assignment. All the other tests behave as expected""" print #tests for question3.py from question3 import sortcat print "sortcat: "
# This is a sample file for how your tests should look like. # To run these tests, make sure you are in the directory that has both your test file (e.g. tests.py) # and the files you want to test (question1, question2, etc.) - this is because the from/import # statements will look for files in whatever path you are currently in # Then run "python FILENAME" (e.g. this file is called sample_test.py, so run "python sample_test.py") # This will run the file, and the file will run the functions and print out the results from pprint import pprint # pretty print output formatting, you don't have to use this, can just use "print" from question2 import swapchars # so in the file question2.py, this will look for a function called "swapchars" print "==testing question 2==" print "swapchars... ", pprint(swapchars("hiiiiii")) print # What should this print? (Answer: "ihhhhhh") # Make sure you record in comments what the result is! It should be what you expect, or else you know # something's wrong with your solution!
# This is a sample file for how your tests should look like. # To run these tests, make sure you are in the directory that has both your test file (e.g. tests.py) # and the files you want to test (question1, question2, etc.) - this is because the from/import # statements will look for files in whatever path you are currently in # Then run "python FILENAME" (e.g. this file is called sample_test.py, so run "python sample_test.py") # This will run the file, and the file will run the functions and print out the results from pprint import pprint # pretty print output formatting, you don't have to use this, can just use "print" from question2 import swapchars # so in the file question2.py, this will look for a function called "swapchars" print "==testing question 2==" print "swapchars... ", pprint(swapchars("hiiiiii")) print # What should this print? (Answer: "ihhhhhh") # Make sure you record in comments what the result is! It should be what you expect, or else you know # something's wrong with your solution!
# Testing question 1. print "==testing question 1==" # Expected output: Numbers 1 through 100, except every multiple of 3, 5, and 15 # are replaced with Fizz, Buzz, and FizzBuzz respectively. fizzbuzz() print print # Testing question 2. # Expected output: print "==testing question 2==" # Expected output: "Thcrc wcrc a lot of cseopcoplcs in thc clcvator on Tucsday." pprint(swapchars("There were a lot of escopeoples in the elevator on Tuesday.")) # Expected output: "ihhhhhh" pprint(swapchars("hiiiiii")) print print # Testing question 3 print "==testing question 3==" # Expected output: 'awesome' pprint(concat(1, "Kyle", "is", "awesome")) # Expected output: 'what???2345' pprint(concat(-1, "what", "???", 5, 234))