def testMethod(): output = lib.outputOf( _fileName, stdinArgs = [23], overwriteAttributes = [("__name__", "__main__")] ) regex = re.compile(".*" "( ##)[ ]*(\n)" "( ###)[ ]*(\n)" "( ####)[ ]*(\n)" "( #####)[ ]*(\n)" "( ######)[ ]*(\n)" "( #######)[ ]*(\n)" "( ########)[ ]*(\n)" "( #########)[ ]*(\n)" "( ##########)[ ]*(\n)" "( ###########)[ ]*(\n)" "( ############)[ ]*(\n)" "( #############)[ ]*(\n)" "( ##############)[ ]*(\n)" "( ###############)[ ]*(\n)" "( ################)[ ]*(\n)" "( #################)[ ]*(\n)" "( ##################)[ ]*(\n)" "( ###################)[ ]*(\n)" "( ####################)[ ]*(\n)" "( #####################)[ ]*(\n)" "( ######################)[ ]*(\n)" "( #######################)[ ]*(\n)" "(########################)[ ]*(\n)" ".*", re.MULTILINE) return asserts.match(output, regex)
def exactMario23(test): test.test = lambda: assertlib.match( lib.outputOf(_fileName, stdinArgs=[23]), re.compile( ".*" "( # #)[ ]*(\n)" "( # # #)[ ]*(\n)" "( # # # #)[ ]*(\n)" "( # # # # #)[ ]*(\n)" "( # # # # # #)[ ]*(\n)" "( # # # # # # #)[ ]*(\n)" "( # # # # # # # #)[ ]*(\n)" "( # # # # # # # # #)[ ]*(\n)" "( # # # # # # # # # #)[ ]*(\n)" "( # # # # # # # # # # #)[ ]*(\n)" "( # # # # # # # # # # # #)[ ]*(\n)" "( # # # # # # # # # # # # #)[ ]*(\n)" "( # # # # # # # # # # # # # #)[ ]*(\n)" "( # # # # # # # # # # # # # # #)[ ]*(\n)" "( # # # # # # # # # # # # # # # #)[ ]*(\n)" "( # # # # # # # # # # # # # # # # #)[ ]*(\n)" "( # # # # # # # # # # # # # # # # # #)[ ]*(\n)" "( # # # # # # # # # # # # # # # # # # #)[ ]*(\n)" "( # # # # # # # # # # # # # # # # # # # #)[ ]*(\n)" "( # # # # # # # # # # # # # # # # # # # # #)[ ]*(\n)" "( # # # # # # # # # # # # # # # # # # # # # #)[ ]*(\n)" "( # # # # # # # # # # # # # # # # # # # # # # #)[ ]*(\n)" "(# # # # # # # # # # # # # # # # # # # # # # # #)[ ]*" ".*", re.MULTILINE)) test.description = lambda: "print een pyramide van 23 hoog"
def exactMario23(test): test.test = lambda: assertlib.match( lib.outputOf(_fileName, stdinArgs=[23]), re.compile( ".*" "( # #)[ ]*(\n)" "( # # #)[ ]*(\n)" "( # # # #)[ ]*(\n)" "( # # # # #)[ ]*(\n)" "( # # # # # #)[ ]*(\n)" "( # # # # # # #)[ ]*(\n)" "( # # # # # # # #)[ ]*(\n)" "( # # # # # # # # #)[ ]*(\n)" "( # # # # # # # # # #)[ ]*(\n)" "( # # # # # # # # # # #)[ ]*(\n)" "( # # # # # # # # # # # #)[ ]*(\n)" "( # # # # # # # # # # # # #)[ ]*(\n)" "( # # # # # # # # # # # # # #)[ ]*(\n)" "( # # # # # # # # # # # # # # #)[ ]*(\n)" "( # # # # # # # # # # # # # # # #)[ ]*(\n)" "( # # # # # # # # # # # # # # # # #)[ ]*(\n)" "( # # # # # # # # # # # # # # # # # #)[ ]*(\n)" "( # # # # # # # # # # # # # # # # # # #)[ ]*(\n)" "( # # # # # # # # # # # # # # # # # # # #)[ ]*(\n)" "( # # # # # # # # # # # # # # # # # # # # #)[ ]*(\n)" "( # # # # # # # # # # # # # # # # # # # # # #)[ ]*(\n)" "( # # # # # # # # # # # # # # # # # # # # # # #)[ ]*(\n)" "(# # # # # # # # # # # # # # # # # # # # # # # #)[ ]*" ".*", re.MULTILINE)) test.description = lambda: "prints a well-formed pyramid of height 23"
def handlesWrongInput(test): notAllowed = {"the * operator, but instead loops": "*"} notAllowedCode(test, lib.source(_fileName), notAllowed) test.test = lambda: assertlib.match( lib.outputOf(_fileName, stdinArgs=[-100, 24, 1]), re.compile(".*(# #)[ ]*(\n)")) test.description = lambda: "rejects heights of -100 and 24, then accepts a height of 1"
def exactMario3(test): test.test = lambda: assertlib.match( lib.outputOf(_fileName, stdinArgs=[3]), re.compile( ".*" "( # #)[ ]*(\n)" "( # # #)[ ]*(\n)" "(# # # #)[ ]*" ".*", re.MULTILINE)) test.description = lambda: "correctly prints a pyramid of height 3"
def testMethod(): output = lib.outputOf( _fileName, argv = ["fifteen.py", "3"], stdinArgs = ["-1"], overwriteAttributes = [("__name__", "__main__")], ignoreExceptions = [SystemExit] ) regex = re.compile("[\s\S]*" "(08 07 06)[ ]*(\n)" "(05 04 03)[ ]*(\n)" "(02 01 __)[ ]*(\n)" "[\s\S]*", re.MULTILINE) return asserts.match(output, regex)
def exactMario0(test): test.test = lambda: assertlib.match(lib.outputOf(_fileName, stdinArgs=[1]), re.compile(".*(# #)[ ]*(\n)")) test.description = lambda: "prints a well-formed pyramid of height 1"
def testMethod(): result = lib.getLine(lib.outputOf(_fileName), 0) testResult = assertlib.match(result, ".*9552.*9586.*") or assertlib.match( result, ".*9586.*9552.*") return testResult
def handlesWrongInput(test): test.test = lambda: assertlib.match( lib.outputOf(_fileName, stdinArgs=[-100, 100, 24, 1]), re.compile(".*(# #)[ ]*(\n)")) test.description = lambda: "Can deal with incorrect input: -100 and 100"
def exactMario0(test): test.test = lambda: assertlib.match(lib.outputOf(_fileName, stdinArgs=[1]), re.compile(".*(# #)[ ]*(\n)")) test.description = lambda: "print een welgevormde pyramide van 1 hoog"
def handlesWrongInput(test): test.test = lambda: assertlib.match( lib.outputOf(_fileName, stdinArgs=[-100, 100, 24, 1]), re.compile(".*(# #)[ ]*(\n)")) test.description = lambda: "handelt verkeerde input netjes af"