コード例 #1
0
ファイル: list_wordsTest.py プロジェクト: uva-sp/sp1
    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()])
コード例 #2
0
ファイル: trumpTest.py プロジェクト: Jelleas/progiktests
 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()))
コード例 #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)
コード例 #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)
コード例 #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'])
コード例 #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'])
コード例 #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"
コード例 #8
0
ファイル: medicineTest.py プロジェクト: Jelleas/progiktests
 def testMethod():
     isResistent = lib.getFunction("isResistent", _fileName)
     return asserts.exact(isResistent("AAA"), True)
コード例 #9
0
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'"
コード例 #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'"
コード例 #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'"
コード例 #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\""
コード例 #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\""
コード例 #14
0
ファイル: helloTest.py プロジェクト: VeraSchild/pwp2018
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"
コード例 #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)
コード例 #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)
コード例 #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\""
コード例 #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\""
コード例 #19
0
ファイル: helloTest.py プロジェクト: VeraSchild/pwp2018
def exactHello(test):
	test.test = lambda : assertlib.exact(lib.outputOf(_fileName), "Hello, world!\n")
	test.description = lambda : "prints exactly: Hello, world!"
コード例 #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"
コード例 #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\""
コード例 #22
0
 def testMethod():
     output = lib.outputOf(_fileName,
                           overwriteAttributes=[("__name__", "__main__")])
     return asserts.exact(output.strip(), "Hello, world!")
コード例 #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\""
コード例 #24
0
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'"
コード例 #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'"
コード例 #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"
コード例 #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'"
コード例 #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"
コード例 #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'"
コード例 #30
0
ファイル: medicineTest.py プロジェクト: Jelleas/progiktests
 def testMethod():
     isResistent = lib.getFunction("isResistent", _fileName)
     return asserts.exact(isResistent("ATGCAATGCAATGGGCCCCTTTAAACCCT"),
                          True)