Ejemplo n.º 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()])
Ejemplo n.º 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()))
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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'])
Ejemplo n.º 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'])
Ejemplo n.º 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"
Ejemplo n.º 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'"
Ejemplo n.º 10
0
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'"
Ejemplo n.º 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'"
Ejemplo n.º 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\""
Ejemplo n.º 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\""
Ejemplo n.º 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"
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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\""
Ejemplo n.º 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\""
Ejemplo n.º 19
0
def exactHello(test):
	test.test = lambda : assertlib.exact(lib.outputOf(_fileName), "Hello, world!\n")
	test.description = lambda : "prints exactly: Hello, world!"
Ejemplo n.º 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"
Ejemplo n.º 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\""
Ejemplo n.º 22
0
 def testMethod():
     output = lib.outputOf(_fileName,
                           overwriteAttributes=[("__name__", "__main__")])
     return asserts.exact(output.strip(), "Hello, world!")
Ejemplo n.º 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'"
Ejemplo n.º 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'"
Ejemplo n.º 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"
Ejemplo n.º 27
0
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'"
Ejemplo n.º 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"
Ejemplo n.º 29
0
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'"
Ejemplo n.º 30
0
 def testMethod():
     isResistent = lib.getFunction("isResistent", _fileName)
     return asserts.exact(isResistent("ATGCAATGCAATGGGCCCCTTTAAACCCT"),
                          True)