Beispiel #1
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()])
Beispiel #2
0
 def testMethod():
     import monopoly
     possession = lib.getFunction("possession", _fileName)
     correct = {
         'dorpstraat': False,
         'brink': False,
         'station zuid': False,
         'steenstraat': False,
         'ketelstraat': False,
         'velperplein': False,
         'barteljorisstraat': False,
         'elecriciteitsbedrijf': False,
         'zijlweg': False,
         'houtstraat': False,
         'station west': False,
         'neude': False,
         'biltstraat': False,
         'vreeburg': False,
         'a-kerkhof': False,
         'groote markt': False,
         'heerestraat': False,
         'station noord': False,
         'spui': False,
         'plein': False,
         'waterleiding': False,
         'lange poten': False,
         'hofplein': False,
         'blaak': False,
         'coolsingel': False,
         'station oost': False,
         'leidschestraat': False,
         'kalverstraat': False
     }
     return asserts.exact(set(possession(monopoly.Board()).keys()),
                          set(correct.keys()))
Beispiel #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), 1)
        if not correct_return:
            return False

        return assertlib.exact(lib.getFunction(function_name, _fileName)(test_text), -1)
Beispiel #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 != 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)
Beispiel #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 != 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'])
Beispiel #6
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'])
Beispiel #7
0
def correct(test):
    test.test = lambda: assertlib.exact(
        sorted(
            int(p * 10) for p in lib.getFunction("roots", _fileName)
            (1, 2, -10)), [-43, 23])
    test.description = lambda: "roots() yields two roots for a=1, b=2, c=-10"
Beispiel #8
0
 def testMethod():
     isResistent = lib.getFunction("isResistent", _fileName)
     return asserts.exact(isResistent("AAA"), True)
def levenshtein_e(test):
    test.test = lambda: assertlib.exact(
        lib.getFunction("levenshtein_distance", _fileName)
        ("sitting", "sittin"), 1)
    test.description = lambda: "levenshtein_distance werkt voor de invoer 'sitting', 'sittin'"
def levenshtein_b(test):
    test.test = lambda: assertlib.exact(
        lib.getFunction("levenshtein_distance", _fileName)
        ("mineur", "majeur"), 4)
    test.description = lambda: "levenshtein_distance werkt voor de invoer 'mineur', 'majeur'"
Beispiel #11
0
def count_exact_matches_0a(test):
    test.test = lambda: assertlib.exact(
        lib.getFunction("count_exact_matches", _fileName)
        ("atgacatgcacaagtatgcat", "b"), 0)
    test.description = lambda: "count_exact_matches works for input 'atgacatgcacaagtatgcat', 'b'"
Beispiel #12
0
def correctInitials3(test):
	test.test = lambda : assertlib.exact(lib.getFunction("initials", _fileName)("Martha Chase").upper(), "MC")
	test.description = lambda : "initials() geeft de correcte initialen van \"Martha Chase\""
Beispiel #13
0
def correctInitials1(test):
	test.test = lambda : assertlib.exact(lib.getFunction("initials", _fileName)("Johann Friedrich Miescher").upper(), "JFM")
	test.description = lambda : "initials() geeft de correcte initialen van \"Johann Friedrich Miescher\""
Beispiel #14
0
def oneLine(test):
	test.test = lambda : assertlib.exact(len(lib.outputOf(_fileName).split("\n")), 2) and assertlib.exact(lib.getLine(lib.outputOf(_fileName), 1), "")
	test.description = lambda : "prints exactly 1 line"
Beispiel #15
0
 def testMethod():
     simulate = lib.getFunction("simulate", _fileName)
     viruses = ["GGGG", "AAAA", "TTTT", "GGGG", "ATGC"] * 20
     return asserts.exact(len(simulate(viruses, 0, 0, 0, 100, 500)), 501)
Beispiel #16
0
 def testMethod():
     reproduce = lib.getFunction("reproduce", _fileName)
     viruses = ["GGGG", "AAAA", "TTTT", "GGGG", "ATGC"] * 20
     return asserts.exact(reproduce(viruses, 0.25, 0), viruses)
Beispiel #17
0
def correctInitials2(test):
    test.test = lambda: assertlib.exact(
        lib.getFunction("initials", _fileName)("Phoebus Levene").upper(), "PL")
    test.description = lambda: "initials() returns the correct initials for \"Phoebus Levene\""
Beispiel #18
0
def correctInitials3(test):
    test.test = lambda: assertlib.exact(
        lib.getFunction("initials", _fileName)("Martha Chase").upper(), "MC")
    test.description = lambda: "initials() returns the correct initials for \"Martha Chase\""
Beispiel #19
0
def exactHello(test):
	test.test = lambda : assertlib.exact(lib.outputOf(_fileName), "Hello, world!\n")
	test.description = lambda : "prints exactly: Hello, world!"
Beispiel #20
0
def correctNone(test):
    test.test = lambda: assertlib.exact(
        sorted(
            int(p * 10)
            for p in lib.getFunction("roots", _fileName)(3, 6, 9)), [])
    test.description = lambda: "roots() yields no roots for a=3, b=6, c=9"
Beispiel #21
0
def correctInitials2(test):
	test.test = lambda : assertlib.exact(lib.getFunction("initials", _fileName)("Phoebus Levene").upper(), "PL")
	test.description = lambda : "initials() geeft de correcte initialen van \"Phoebus Levene\""
Beispiel #22
0
 def testMethod():
     output = lib.outputOf(_fileName,
                           overwriteAttributes=[("__name__", "__main__")])
     return asserts.exact(output.strip(), "Hello, world!")
Beispiel #23
0
def almostWrongInput(test):
	test.test = lambda : assertlib.exact(lib.getFunction("initials", _fileName)("John  Double  Spaces").upper(), "JDS")
	test.description = lambda : "initials() geeft de correcte initialen van \"John  Double  Spaces\""
def count_exact_matches_8(test):
    test.test = lambda: assertlib.exact(
        lib.getFunction("count_exact_matches", _fileName)
        ("atgacatgcacaagtatgcat", "a"), 8)
    test.description = lambda: "count_exact_matches werkt voor invoer 'atgacatgcacaagtatgcat', 'a'"
Beispiel #25
0
def count_exact_matches_0b(test):
    test.test = lambda: assertlib.exact(
        lib.getFunction("count_exact_matches", _fileName)("", "atgc"), 0)
    test.description = lambda: "count_exact_matches works for input '', 'atgc'"
Beispiel #26
0
def correct(test):
    test.test = lambda: assertlib.exact(
        sorted(
            int(p * 10) for p in lib.getFunction("nulpunten", _fileName)
            (1, 2, -10)), [-43, 23])
    test.description = lambda: "vind de nulpunten voor invoer a=1, b=2, c=-10"
def levenshtein_c(test):
    test.test = lambda: assertlib.exact(
        lib.getFunction("levenshtein_distance", _fileName)
        ("kitten", "sitting"), 5)
    test.description = lambda: "levenshtein_distance werkt voor de invoer 'kitten', 'sitting'"
Beispiel #28
0
def correctNone(test):
    test.test = lambda: assertlib.exact(
        sorted(
            int(p * 10)
            for p in lib.getFunction("nulpunten", _fileName)(3, 6, 9)), [])
    test.description = lambda: "vind geen nulpunten voor invoer a=3, b=6, c=9"
def levenshtein_g(test):
    test.test = lambda: assertlib.exact(
        lib.getFunction("levenshtein_distance", _fileName)("", "hello"), 5)
    test.description = lambda: "levenshtein_distance werkt voor de invoer '', 'hello'"
Beispiel #30
0
 def testMethod():
     isResistent = lib.getFunction("isResistent", _fileName)
     return asserts.exact(isResistent("ATGCAATGCAATGGGCCCCTTTAAACCCT"),
                          True)