def correctDateLowestTemp(test): tsts = ['1', 'januari', 'January'] test.test = lambda : assertlib.contains(lib.outputOf(_fileName), '27') and\ sum([assertlib.contains(lib.outputOf(_fileName), tst) for tst in tsts])\ and assertlib.contains(lib.outputOf(_fileName), '1942') test.description = lambda: "print datum laagste temperatuur" test.timeout = lambda: 60
def correctDateLongestFreezingp(test): tsts = ['2', 'februari', 'February'] test.test = lambda : assertlib.contains(lib.outputOf(_fileName), ' 24 ') and\ sum([assertlib.contains(lib.outputOf(_fileName), tst) for tst in tsts])\ and assertlib.contains(lib.outputOf(_fileName), '1947') test.description = lambda: "print laatste dag van de langste periode dat het aaneengesloten heeft gevroren" test.timeout = lambda: 60
def correctDateHighestTemp(test): tsts = ['6', 'juni', 'June'] test.test = lambda : assertlib.contains(lib.outputOf(_fileName), '27') and\ sum([assertlib.contains(lib.outputOf(_fileName), tst) for tst in tsts])\ and assertlib.contains(lib.outputOf(_fileName), '1947') test.description = lambda: "print datum hoogste temperatuur" test.timeout = lambda: 60
def testMethod(): #Max temp correctAnswerMax = [37.5, 25, 2019] if helpers.isHardcodedIn(correctAnswerMax[0], test.fileName): test.success = lambda info: "let op: deze output is hardcoded. {} staat in de source code!".format( correctAnswer) line1 = lib.getLine(lib.outputOf(_fileName), 0) numbersMax = lib.getNumbersFromString(line1) correctMonthMax = any([ assertlib.contains(line1.lower(), month) for month in ["juli", "june", "jun"] ]) #Min temp correctAnswerMin = [-24.7, 27, 1942] line2 = lib.getLine(lib.outputOf(_fileName), 1) numbersMin = lib.getNumbersFromString(line2) correctMonthMin = any([ assertlib.contains(line1.lower(), month) for month in ["januari", "january", "jan"] ]) #Total check if sum(1 for n in numbersMax if n in correctAnswerMax) != 3 and correctMonthMax and sum( 1 for n in numbersMin if n in correctAnswerMin) != 3 and correctMonthMin: return False return True
def testMethod(): if helpers.isHardcodedIn(1942, test.fileName): test.success = lambda info : "watch out: 1942 appears to be hardcoded!" output = lib.outputOf( test.fileName, overwriteAttributes = [("__name__", "__main__")] ) line = helpers.findLineWith(output, "-24.8") correctDay = assertlib.contains(line, '27') correctMonth = any([assertlib.contains(line.lower(), month) for month in ["1", "januari", "january", "jan"]]) correctYear = assertlib.contains(line, '1942') return correctDay and correctMonth and correctYear
def testMethod(): if helpers.isHardcodedIn(1947, test.fileName): test.success = lambda info: "let op: deze output is hardcoded. 1947 staat in de source code!" output = lib.outputOf(test.fileName, overwriteAttributes=[("__name__", "__main__")]) line = helpers.findLineWith(output, "36.8") correctDay = assertlib.contains(line, '27') correctMonth = any([ assertlib.contains(line.lower(), month) for month in ["6", "juni", "june", "jun"] ]) correctYear = assertlib.contains(line, '1947') return correctDay and correctMonth and correctYear
def testMethod(): if helpers.isHardcodedIn(1947, test.fileName): test.success = lambda info: "watch out: 1947 appears to be hardcoded!" output = lib.outputOf(test.fileName, overwriteAttributes=[("__name__", "__main__")]) line = helpers.findLineWith(output, "21") correctDay = assertlib.contains(line, '24') correctMonth = any([ assertlib.contains(line.lower(), month) for month in ["februari", "february", "feb"] ]) correctYear = assertlib.contains(line, '1947') return correctDay and correctMonth and correctYear, "Did you print the date on the same line as the longest period of frost?"
def testMethod(): output = lib.outputOf(_fileName, argv=["find.py"], overwriteAttributes=[("__name__", "__main__")], ignoreExceptions=[SystemExit]) line = lib.getLine(output, 0) return asserts.contains(line, "usage: python find.py needle haystack")
def testMethod(): output = lib.outputOf( _fileName, stdinArgs = [-1, 0], overwriteAttributes = [("__name__", "__main__")] ) return not asserts.contains(output, "#")
def exactMario23(test): test.test = lambda: assertlib.contains( lib.outputOf(_fileName, [23]), """ # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #""") test.description = lambda: "print een pyramide van 23 hoog"
def exactMario23(test): test.test = lambda : assertlib.contains(lib.outputOf(_fileName, [23]), """ ## ### #### ##### ###### ####### ######## ######### ########## ########### ############ ############# ############## ############### ################ ################# ################## ################### #################### ##################### ###################### ####################### ########################""") test.description = lambda : "prints a pyramid of height 23"
def testMethod(): output = lib.outputOf(_fileName, argv=["vigenere.py", "a"], stdinArgs=["a"], overwriteAttributes=[("__name__", "__main__")]) line = lib.getLine(output, 0) return asserts.contains(line, "a")
def testMethod(): output = lib.outputOf(_fileName, argv=["vigenere.py", "foo", "bar"], stdinArgs=["foo"], overwriteAttributes=[("__name__", "__main__")], ignoreExceptions=[SystemExit]) line = lib.getLine(output, 0) return asserts.contains(line, "usage: python vigenere.py keyword")
def testMethod(): output = lib.outputOf( _fileName, argv = ["caesar.py", "65"], stdinArgs = ["barfoo"], overwriteAttributes = [("__name__", "__main__")] ) line = lib.getLine(output, 0) return asserts.contains(line, "onesbb")
def testMethod(): correctAnswer = "-24.8" if helpers.isHardcodedIn(correctAnswer, test.fileName): test.success = lambda info: "let op: deze output is hardcoded. {} staat in de source code!".format( correctAnswer) output = lib.outputOf(test.fileName, overwriteAttributes=[("__name__", "__main__")]) return assertlib.contains(output, correctAnswer)
def correctAbove60(test): tsts = ['60', 'zestig', 'sixty'] test.test = lambda: (assertlib.numberOnLine( 5, lib.getLine(lib.outputOf(_fileName), 1), deviation=5 ) or assertlib.numberOnLine( 0.05, lib.getLine(lib.outputOf(_fileName), 1), deviation=0.05 )) and sum( [assertlib.contains(lib.outputOf(_fileName), tst) for tst in tsts]) test.description = lambda: "print op de tweede regel hoe vaak de som meer dan 60 is"
def correctBelow40(test): tsts = ['40', 'veertig', 'forty'] test.test = lambda: (assertlib.numberOnLine( 5, lib.getLine(lib.outputOf(_fileName), 0), deviation=5 ) or assertlib.numberOnLine( 0.05, lib.getLine(lib.outputOf(_fileName), 0), deviation=0.05 )) and sum( [assertlib.contains(lib.outputOf(_fileName), tst) for tst in tsts]) test.description = lambda: "print op de eerste regel hoe vaak de som minder dan 40 is"
def testMethod(): correctAnswer = "-24.8" if helpers.isHardcodedIn(correctAnswer, test.fileName): test.success = lambda info: "watch out: {} appears to be hardcoded!".format( correctAnswer) output = lib.outputOf(test.fileName, overwriteAttributes=[("__name__", "__main__")]) return assertlib.contains(output, correctAnswer)
def testMethod(): output = lib.outputOf( _fileName, argv = ["caesar.py", "3"], stdinArgs = ["BARFOO"], overwriteAttributes = [("__name__", "__main__")] ) line = lib.getLine(output, 0) return asserts.contains(line, "EDUIRR")
def testMethod(): output = lib.outputOf( _fileName, argv = ["fifteen.py", "4"], stdinArgs = ["4","5","6","1","2","4","5","6","1","2","3","7","11","10","9","1","2","3","4","5","6","8","1","2","3","4","7","11","10","9","14","13","12","1","2","3","4","14","13","12","1","2","3","4","14","13","12","1","2","3","4","12","9","15","1","2","3","4","12","9","13","14","9","13","14","7","5","9","13","14","15","10","11","5","9","13","7","11","5","9","13","7","11","15","10","5","9","13","15","11","8","6","7","8","14","12","6","7","8","14","12","6","7","8","14","15","11","10","6","7","8","12","15","11","10","15","11","14","12","11","15","10","14","15","11","12"], overwriteAttributes = [("__name__", "__main__")], ignoreExceptions = [SystemExit] ) failInfo = output.split("\n")[-6:] return asserts.contains(output, "You have won!"), failInfo
def correctBelow40(test): tsts = ['40', 'veertig', 'forty'] test.test = lambda: (assertlib.numberOnLine( 5, lib.getLine(lib.outputOf(_fileName), 0), deviation=5 ) or assertlib.numberOnLine( 0.05, lib.getLine(lib.outputOf(_fileName), 0), deviation=0.05 )) and sum( [assertlib.contains(lib.outputOf(_fileName), tst) for tst in tsts]) test.fail = lambda info: "make sure you output a sentence containing the answer on the first line of output" test.description = lambda: "prints, on the first line, how often the sum is less than 40"
def correctAbove60(test): tsts = ['60', 'zestig', 'sixty'] test.test = lambda: (assertlib.numberOnLine( 5, lib.getLine(lib.outputOf(_fileName), 1), deviation=5 ) or assertlib.numberOnLine( 0.05, lib.getLine(lib.outputOf(_fileName), 1), deviation=0.05 )) and sum( [assertlib.contains(lib.outputOf(_fileName), tst) for tst in tsts]) test.fail = lambda info: "make sure you output a sentence containing the answer on the second line of output" test.description = lambda: "prints, on the first line, how often the sum is more than 60"
def testMethod(): if helpers.isHardcodedIn(1947, test.fileName): test.success = lambda info: "let op: deze output is hardcoded. 1947 staat in de source code!" line1 = lib.getLine(lib.outputOf(_fileName), 2) correctDuration = assertlib.contains(line1, '21') line2 = lib.getLine(lib.outputOf(_fileName), 3) correctMonth = any([ assertlib.contains(line2.lower(), month) for month in ["februari", "february", "feb"] ]) correctAnswer = [4, 24, 1947] numbers = lib.getNumbersFromString(line2) correctDayAndYear = sum(1 for n in numbers if n in correctAnswer) == 4 return correctDuration and correctMonth and correctDayAndYear
def exactMario0(test): test.test = lambda: not assertlib.contains(lib.outputOf(_fileName, [0]), "#") test.description = lambda: "print een pyramide van 0 hoog"
def handlesWrongInput(test): test.test = lambda: not assertlib.contains( lib.outputOf(_fileName, [-100, 100, 24, 0]), "#") test.description = lambda: "handelt een verkeerde input van -100, 100 en 24 af"
def correctLowestTemp(test): test.test = lambda: assertlib.contains(lib.outputOf(_fileName), '-24.8') test.description = lambda: "print laagste temperatuur"
def findline(outputOf): tsts = ['startgeld', 'evenveel', 'straten'] for line in outputOf.split("\n"): if all([assertlib.contains(line, tst) for tst in tsts]): return line return ""
def correctHighestTemp(test): test.test = lambda: assertlib.contains(lib.outputOf(_fileName), '36.8') test.description = lambda: "print hoogste temperatuur"
def correctFirstHeatWave(test): test.test = lambda: assertlib.contains(lib.outputOf(_fileName), '1911') test.description = lambda: "print het eerste jaartal waarin er sprake was van een hittegolf"
def correctLongestFreezing(test): test.test = lambda: assertlib.contains(lib.outputOf(_fileName), '21') test.description = lambda: "print de langste periode dat het aaneengesloten heeft gevroren"