Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
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
Ejemplo n.º 3
0
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
Ejemplo n.º 4
0
    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
Ejemplo n.º 5
0
	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
Ejemplo n.º 6
0
    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
Ejemplo n.º 7
0
    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?"
Ejemplo n.º 8
0
 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")
Ejemplo n.º 9
0
	def testMethod():
		output = lib.outputOf(
            _fileName,
            stdinArgs = [-1, 0],
            overwriteAttributes = [("__name__", "__main__")]
        )
		return not asserts.contains(output, "#")
Ejemplo n.º 10
0
def exactMario23(test):
    test.test = lambda: assertlib.contains(
        lib.outputOf(_fileName, [23]),
        """                                            # #
                                          # # #
                                        # # # #
                                      # # # # #
                                    # # # # # #
                                  # # # # # # #
                                # # # # # # # #
                              # # # # # # # # #
                            # # # # # # # # # #
                          # # # # # # # # # # #
                        # # # # # # # # # # # #
                      # # # # # # # # # # # # #
                    # # # # # # # # # # # # # #
                  # # # # # # # # # # # # # # #
                # # # # # # # # # # # # # # # #
              # # # # # # # # # # # # # # # # #
            # # # # # # # # # # # # # # # # # #
          # # # # # # # # # # # # # # # # # # #
        # # # # # # # # # # # # # # # # # # # #
      # # # # # # # # # # # # # # # # # # # # #
    # # # # # # # # # # # # # # # # # # # # # #
  # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # #""")
    test.description = lambda: "print een pyramide van 23 hoog"
Ejemplo n.º 11
0
def exactMario23(test):
	test.test = lambda : assertlib.contains(lib.outputOf(_fileName, [23]),
"""                      ##
                     ###
                    ####
                   #####
                  ######
                 #######
                ########
               #########
              ##########
             ###########
            ############
           #############
          ##############
         ###############
        ################
       #################
      ##################
     ###################
    ####################
   #####################
  ######################
 #######################
########################""")
	test.description = lambda : "prints a pyramid of height 23"
Ejemplo n.º 12
0
 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")
Ejemplo n.º 13
0
 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")
Ejemplo n.º 14
0
 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")
Ejemplo n.º 15
0
    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)
Ejemplo n.º 16
0
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"
Ejemplo n.º 17
0
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"
Ejemplo n.º 18
0
    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)
Ejemplo n.º 19
0
 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")
Ejemplo n.º 20
0
 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
Ejemplo n.º 21
0
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"
Ejemplo n.º 22
0
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"
Ejemplo n.º 23
0
    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
Ejemplo n.º 24
0
def exactMario0(test):
    test.test = lambda: not assertlib.contains(lib.outputOf(_fileName, [0]),
                                               "#")
    test.description = lambda: "print een pyramide van 0 hoog"
Ejemplo n.º 25
0
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"
Ejemplo n.º 26
0
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 ""
Ejemplo n.º 28
0
def correctHighestTemp(test):
    test.test = lambda: assertlib.contains(lib.outputOf(_fileName), '36.8')
    test.description = lambda: "print hoogste temperatuur"
Ejemplo n.º 29
0
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"
Ejemplo n.º 30
0
def correctLongestFreezing(test):
    test.test = lambda: assertlib.contains(lib.outputOf(_fileName), '21')
    test.description = lambda: "print de langste periode dat het aaneengesloten heeft gevroren"