Пример #1
0
    def testMethod():
        nArguments = len(
            lib.getFunction("simuleer_groot_aantal_potjes_monopoly",
                            _fileName).arguments)

        # Trump
        if nArguments == 1:
            testInput = lib.getFunction(
                "simuleer_groot_aantal_potjes_monopoly", _fileName)(1000)
            test.success = lambda info: "De code werkt zonder startgeld, je kunt nu startgeld invoeren!"
            if assertlib.sameType(
                    lib.getFunction("simuleer_groot_aantal_potjes_monopoly",
                                    _fileName)(10000), None):
                test.fail = lambda info: "Zorg er voor dat de functie simuleer_groot_aantal_potjes_monopoly het gemiddeld aan benodigde worpen returnt en ook alleen deze waarde returnt"

        # Stargeld, 1 speler
        elif nArguments == 2:
            twoArguments = True
            testInput = lib.getFunction(
                "simuleer_groot_aantal_potjes_monopoly", _fileName)(1000,
                                                                    1000000)
            if assertlib.sameType(
                    lib.getFunction("simuleer_groot_aantal_potjes_monopoly",
                                    _fileName)(10000, 1000000), None):
                test.fail = lambda info: "Zorg er voor dat de functie simuleer_groot_aantal_potjes_monopoly het gemiddeld aan benodigde worpen returnt en ook alleen deze waarde returnt"

        else:
            testInput = False
            test.fail = lambda info: "Zorg er voor dat de functie simuleer_groot_aantal_potjes_monopoly bij Trumpmode 1 argument heeft en bij starggeld 2 argumenten"

        return testInput
Пример #2
0
    def testMethod():
        hasfunction = assertlib.fileContainsFunctionDefinitions(
            _fileName, function_name)
        if not hasfunction:
            info = "Make sure you use a function named " + function_name + " as you're writing your code."
            return False, info

        nArguments = len(lib.getFunction(function_name, _fileName).arguments)
        if nArguments != 1:
            info = "Make sure your function has 1 argument."
            return False, info

        correct_return = assertlib.sameType(
            lib.getFunction(function_name, _fileName)(test_text), [])
        if not correct_return:
            info = "Make sure you return an list and nothing else."
            return False, info

        if assertlib.exact(
                lib.getFunction(function_name, _fileName)(test_text),
            [test_text]):
            info = "Make sure that all letters are lowercase."
            return False, info

        if not assertlib.exact(
                lib.getFunction(function_name, _fileName)(""), []):
            info = "For an empty text, the list of words should be empty"
            return False, info

        return assertlib.exact(
            lib.getFunction(function_name, _fileName)(""),
            []) and assertlib.exact(
                lib.getFunction(function_name, _fileName)(test_text),
                [test_text.lower()])
Пример #3
0
    def testMethod():
        hasfunction = assertlib.fileContainsFunctionDefinitions(
            _fileName, function_name)
        if not hasfunction:
            return False

        nArguments = len(lib.getFunction(function_name, _fileName).arguments)
        if nArguments != 1:
            return False

        correct_return = assertlib.sameType(
            lib.getFunction(function_name, _fileName)(test_text), [])
        if not correct_return:
            return False

        output = lib.getFunction(function_name, _fileName)(test_text)
        output.sort()

        if "boy's" not in output:
            info = "Make sure to deal in the right way with punctuations."
            return False, info

        if "festive," in output or "season." in output:
            info = "Make sure there are no periods and/or commas left in list."

        return output == correctlist
Пример #4
0
    def testMethod():
        hasfunction = assertlib.fileContainsFunctionDefinitions(
            _fileName, function_name)
        if not hasfunction:
            info = "Make sure you use a function named " + function_name + " as you're writing your code."
            return False, info

        nArguments = len(lib.getFunction(function_name, _fileName).arguments)
        if nArguments != 2:
            info = "Make sure your function has 2 argument."
            return False, info

        correct_return = assertlib.sameType(
            lib.getFunction(function_name, _fileName)(test_text, max_length),
            "abc")
        if not correct_return:
            info = "Make sure you return an string and nothing else."
            return False, info

        outputtext = lib.getFunction(function_name, _fileName)(test_text,
                                                               max_length)

        if "  " in outputtext:
            info = "Make sure there are no double spaces in the reformatted text."
            return False, info
        if " \n" in outputtext:
            info = "Make sure lines don't start with a white space."
            return False, info
        elif "\n " in outputtext:
            info = "Make sure lines don't end with a white space (after the enter)."
            return False, info

        return True
Пример #5
0
    def testMethod():
        hasfunction = assertlib.fileContainsFunctionDefinitions(
            _fileName, function_name)
        if not hasfunction:
            return False

        nArguments = len(lib.getFunction(function_name, _fileName).arguments)
        if nArguments != 2:
            return False

        correct_return = assertlib.sameType(
            lib.getFunction(function_name, _fileName)(test_text, max_length),
            "abc")
        if not correct_return:
            return False

        reformatted_test_text = ""
        test_text_splitup = test_text.split()

        counter = 0
        for word in test_text_splitup:
            if reformatted_test_text == "":
                reformatted_test_text = word
                counter += len(word)
            elif len(word) + counter < max_length:
                reformatted_test_text += " " + word
                counter += len(word) + 1
            else:
                reformatted_test_text += "\n" + word
                counter = len(word)

        outputtext = lib.getFunction(function_name, _fileName)(test_text,
                                                               max_length)
        return outputtext == reformatted_test_text
	def try_run():
		try:
			testInput = lib.getFunction("simuleer_groot_aantal_potjes_Monopoly", _fileName)()
			test.fail = lambda info : "Zorg dat de functie simuleer_groot_aantal_potjes_Monopoly als argument het aantal potjes heeft"
			return False
		except:
			try:	
				testInput = lib.getFunction("simuleer_groot_aantal_potjes_Monopoly", _fileName)(10000)
				test.success = lambda info : "De code werkt zonder startgeld, je kunt nu startgeld invoeren!"
				if assertlib.sameType(lib.getFunction("simuleer_groot_aantal_potjes_Monopoly", _fileName)(10000), None):
					test.fail = lambda info : "Zorg er voor dat de functie simuleer_groot_aantal_potjes_Monopoly het gemiddeld aan benodigde worpen returnt en ook alleen deze waarde returnt"
				return testInput
			except:
				testInput = lib.getFunction("simuleer_groot_aantal_potjes_Monopoly", _fileName)(10000, 1000000)
				if assertlib.sameType(lib.getFunction("simuleer_groot_aantal_potjes_Monopoly", _fileName)(10000, 1000000), None):
					test.fail = lambda info : "Zorg er voor dat de functie simuleer_groot_aantal_potjes_Monopoly het gemiddeld aan benodigde worpen returnt en ook alleen deze waarde returnt"
				return testInput
	def testMethod():
		outcome = lib.getFunction("simuleer_groot_aantal_potjes_Monopoly", _fileName)(10000, 1500, 1500)
		if assertlib.sameType(outcome, None):
			info = "Zorg er voor dat de functie simuleer_groot_aantal_potjes_Monopoly het verschil in het bezit van straten returnt en alleen deze waarde returnt"
		elif assertlib.between(outcome, 0, 99999999):
			info = "Als speler 1 meer straten heeft dan speler 2 is het verschil negatief"
		else:
			info = "Het verschil is niet erg groot, gemiddeld zelfs minder dan 1 straat"
		return assertlib.between(outcome, -.45, -.15), info
Пример #8
0
	def testMethod():
		outcome = lib.getFunction("simulate_monopoly_games", _fileName)(10000, 1500, 1500)
		if assertlib.sameType(outcome, None):
			info = "Make sure that the function simulate_monopoly_games only returns the difference in the number of streets owned"
		elif assertlib.between(outcome, -99999999, 0):
			info = "Are you sure you are subtracting player 2s values from player 1 and not the other way around?"
		else:
			info = "When starting both with 1500, the difference in street ownership is not that big, it should be somewhere between .15 and .55."
		return assertlib.between(outcome, .15, .55), info
Пример #9
0
    def testMethod():
        student_func = lib.getFunction("simulate_monopoly_games", _fileName)
        nArguments = len(student_func.arguments)

        if nArguments == 2:
            testInput = student_func(10000, 1500)
            if assertlib.sameType(testInput, None):
                test.fail = lambda info: "Make sure that the function simulate_monopoly_games returns the average required number of throws and nothing else"
            return testInput
        else:
            return 0
Пример #10
0
    def testMethod():
        student_func = lib.getFunction("simulate_monopoly_games", _fileName)
        nArguments = len(student_func.arguments)

        # Trump
        if nArguments == 1:
            testInput = student_func(10000)
            test.success = lambda info: "The code works without starting_money, you can now proceed with starting_money!"
            if assertlib.sameType(testInput, None):
                test.fail = lambda info: "Make sure that the function simulate_monopoly_games returns the average required number of throws and nothing else"

        # starting money, 1 player
        elif nArguments == 2:
            testInput = student_func(10000, 1000000)
            if assertlib.sameType(testInput, None):
                test.fail = lambda info: "Make sure that the function simulate_monopoly_games returns the average required number of throws and nothing else"

        else:
            testInput = False
            test.fail = lambda info: "Make sure that the function simulate_monopoly_games with Trumpmode uses 1 argument and with starting_money 2 arguments"

        return testInput
Пример #11
0
    def testMethod():
        hasfunction = assertlib.fileContainsFunctionDefinitions(_fileName, function_name)
        if not hasfunction:
            return False
        
        nArguments = len(lib.getFunction(function_name, _fileName).arguments)
        if nArguments != 1:
            return False

        correct_return = assertlib.sameType(lib.getFunction(function_name, _fileName)(test_text), 1)
        if not correct_return:
            return False

        return assertlib.exact(lib.getFunction(function_name, _fileName)(test_text), -1)
Пример #12
0
    def testMethod():
        nArguments = len(
            lib.getFunction("simuleer_groot_aantal_potjes_monopoly",
                            _fileName).arguments)

        if nArguments == 2:
            testInput = lib.getFunction(
                "simuleer_groot_aantal_potjes_monopoly", _fileName)(10000,
                                                                    1500)
            if assertlib.sameType(
                    lib.getFunction("simuleer_groot_aantal_potjes_monopoly",
                                    _fileName)(10000, 1500), None):
                test.fail = lambda info: "Zorg er voor dat de functie simuleer_groot_aantal_potjes_monopoly het gemiddeld aan benodigde worpen returnt en ook alleen deze waarde returnt"
            return testInput
        else:
            return 0
Пример #13
0
    def testMethod():
        hasfunction = assertlib.fileContainsFunctionDefinitions(_fileName, function_name)
        if not hasfunction:
            info = "Make sure you use a function named " + function_name + " as you're writing your code."
            return False, info
        
        nArguments = len(lib.getFunction(function_name, _fileName).arguments)
        if nArguments != 1:
            info = "Make sure your function has 1 argument."
            return False, info

        correct_return = assertlib.sameType(lib.getFunction(function_name, _fileName)(test_text), 1)
        if not correct_return:
            info = "Make sure you return an list and nothing else."
            return False, info

        return assertlib.exact(lib.getFunction(function_name, _fileName)(test_text), 1)
Пример #14
0
    def testMethod():
        hasfunction = assertlib.fileContainsFunctionDefinitions(_fileName, function_name)
        if not hasfunction:
            return False
        
        nArguments = len(lib.getFunction(function_name, _fileName).arguments)
        if nArguments != 1:
            return False

        correct_return = assertlib.sameType(lib.getFunction(function_name, _fileName)(test_text), [])
        if not correct_return:
            return False

        if "boy's" not in lib.getFunction(function_name, _fileName)(test_text):
            info = "Make sure to deal in the right way with punctuations."
            return False, info

        return assertlib.exact(lib.getFunction(function_name, _fileName)(test_text), ['stick', "boy's", 'festive', 'season'])
Пример #15
0
    def testMethod():
        hasfunction = assertlib.fileContainsFunctionDefinitions(_fileName, function_name)
        if not hasfunction:
            return False
        
        nArguments = len(lib.getFunction(function_name, _fileName).arguments)
        if nArguments != 1:
            return False

        correct_return = assertlib.sameType(lib.getFunction(function_name, _fileName)(test_text), [])
        if not correct_return:
            return False

        if "" in lib.getFunction(function_name, _fileName)(test_text):
            info = "Make sure to deal in the right way with punctuations."
            return False, info

        return assertlib.exact(lib.getFunction(function_name, _fileName)(test_text), ['stick', 'boy', 'noticed', 'that', 'his', 'christmas', 'tree', 'looked', 'healtier', 'than', 'he', 'did'])
Пример #16
0
    def testMethod():
        hasfunction = assertlib.fileContainsFunctionDefinitions(
            _fileName, function_name)
        if not hasfunction:
            return False

        nArguments = len(lib.getFunction(function_name, _fileName).arguments)
        if nArguments != 1:
            return False

        correct_return = assertlib.sameType(
            lib.getFunction(function_name, _fileName)(test_text), [])
        if not correct_return:
            return False

        if "" in lib.getFunction(function_name, _fileName)(test_text):
            info = "Make sure to deal in the right way with punctuations."
            return False, info

        output = lib.getFunction(function_name, _fileName)(test_text)
        output.sort()
        return output == correctlist
Пример #17
0
def returnTypeIsList(test):
    test.test = lambda: assertlib.sameType(
        lib.getFunction("nulpunten", _fileName)(1, 2, -10), [])
    test.description = lambda: "nulpunten geeft een lijst terug"
Пример #18
0
def returnTypeIsList(test):
    test.test = lambda: assertlib.sameType(
        lib.getFunction("roots", _fileName)(1, 2, -10), [])
    test.description = lambda: "roots() returns a list"
Пример #19
0
def is_list_exact_matches(test):
    test.test = lambda: assertlib.sameType(
        lib.getFunction("exact_matches", _fileName)("a", "a"), [])
    test.description = lambda: "exact_matches returns a list"
Пример #20
0
def is_int_count_exact_matches(test):
    test.test = lambda: assertlib.sameType(
        lib.getFunction("count_exact_matches", _fileName)("a", "a"), 0)
    test.description = lambda: "count_exact_matches returns the right integer"
def is_list_fuzzy_matches(test):
    test.test = lambda: assertlib.sameType(
        lib.getFunction("fuzzy_matches", _fileName)("a", "a"), [])
    test.description = lambda: "fuzzy_matches geeft een lijst terug"
def is_list_split_needle(test):
    test.test = lambda: assertlib.sameType(
        lib.getFunction("split_needle", _fileName)("a"), [])
    test.description = lambda: "split_needle geeft een lijst terug"
def is_int_count_exact_matches(test):
    test.test = lambda: assertlib.sameType(
        lib.getFunction("count_exact_matches", _fileName)("a", "a"), 0)
    test.description = lambda: "count_exact_matches geeft een integer terug"
def is_int_levenshtein(test):
    test.test = lambda: assertlib.sameType(
        lib.getFunction("levenshtein_distance", _fileName)("a", "b"), 0)
    test.description = lambda: "levenshtein_distance geeft een int terug"
Пример #25
0
 def testMethod():
     import monopoly
     possession = lib.getFunction("possession", _fileName)
     return asserts.sameType(possession(monopoly.Board()), dict())