示例#1
0
文件: tests.py 项目: cscenter/EDIDE
def test_windows():
    windows = get_task_windows()

    if "number" in windows[0] and "number" in windows[1]:
        passed()
    else:
        failed("Use % operator")
def test_published_date1():
    placeholders = get_answer_placeholders()
    placeholder = placeholders[2]
    if "DateTimeField" in placeholder and "blank" in placeholder and "null" in placeholder:
        passed()
    else:
        failed("Define variable as DateTimeField(blank=True, null=True)")
def test_published_date():
    placeholders = get_answer_placeholders()
    placeholder = placeholders[2]
    if "published_date" in placeholder:
        passed()
    else:
        failed("Define published_date variable")
def test_answer_placeholders1():
    placeholders = get_answer_placeholders()
    placeholder = placeholders[0]
    if "views.post_list" in placeholder:
        passed()
    else:
        failed("Map url to the views.post_list")
def test_answer_placeholders():
    placeholders = get_answer_placeholders()
    placeholder = placeholders[0]
    if placeholder == "models.Model":
        passed()
    else:
        failed("Use models.Model as an ancestor")
def test_title():
    placeholders = get_answer_placeholders()
    placeholder = placeholders[1]
    if "title" in placeholder:
        passed()
    else:
        failed("Define title variable")
def test_title1():
    placeholders = get_answer_placeholders()
    placeholder = placeholders[1]
    if "CharField" in placeholder and "max_length" in placeholder and "200" in placeholder:
        passed()
    else:
        failed("Create models.CharField(max_length=200) here")
def test_window():
    window = get_answer_placeholders()[0]

    if " in " in window:
        passed()
    else:
        failed("Use 'in' operator for this check")
def test_ice_cream():
    window = get_answer_placeholders()[0]

    if "ice cream" in window or "ice_cream":
        passed()
    else:
        failed("Check if there is 'ice' in 'ice cream'")
示例#10
0
def test_windows():
    windows = get_answer_placeholders()

    if "number" in windows[0] and "number" in windows[1]:
        passed()
    else:
        failed("Use % operator")
示例#11
0
def test_answer_placeholders():
    placeholders = get_answer_placeholders()
    placeholder = placeholders[0]
    if placeholder.find('service_address') != -1:
        passed()
    else:
        failed('Sorry that is not correct. Check the Hint for more help.')
示例#12
0
def test_answer_placeholders2():
    placeholders = get_answer_placeholders()
    placeholder = placeholders[0]
    if "{{" in placeholder and "}}" in placeholder and "post" in placeholder:
        passed()
    else:
        failed("Use {{ post }} to print post content")
示例#13
0
def test_answer_placeholders():
    placeholders = get_answer_placeholders()
    placeholder = placeholders[0]
    if "{%" in placeholder and "%}" in placeholder and "for" in placeholder:
        passed()
    else:
        failed("Use '{% for ... in ... %}' tag")
示例#14
0
def test_answer_placeholders():
    placeholders = get_answer_placeholders()
    placeholder = placeholders[1]
    if "raw_input(" in placeholder:
        passed()
    else:
        failed("Remember to use raw_input(prompt)")
示例#15
0
def test_answer_placeholders1():
    placeholders = get_answer_placeholders()
    placeholder = placeholders[0]
    if "{%" in placeholder and "%}" in placeholder and "endfor" in placeholder:
        passed()
    else:
        failed("Don't forget to close for tag")
示例#16
0
文件: tests.py 项目: cscenter/EDIDE
def test_value():
    file = import_task_file()

    if file.greetings == "greetings":
        failed("You should assign different value to the variable")
    else:
        passed()
示例#17
0
def test_answer_placeholders():
    placeholders = get_answer_placeholders()
    placeholder = placeholders[0]
    if (placeholder[:7] == 'print("' or placeholder[:7] == "print('") and (placeholder[-2:] == '")' or placeholder[-2:] == "')") :
        passed()
    else:
        failed()
示例#18
0
def test_answer_placeholders():
    placeholders = get_answer_placeholders()
    placeholder = placeholders[0]
    if placeholder == "%a %b %d %Y %I:%M:%S%p":
        passed()
    else:
        failed('Sorry, that is not correct. Check the Hint for the correct answer.')
示例#19
0
def test_answer_placeholders():
    placeholders = get_answer_placeholders()
    placeholder = placeholders[0].replace('"', "'")
    if placeholder == "'%(asctime)s %(levelname)s %(message)s'":
        passed()
    else:
        failed()
示例#20
0
def test_answer_placeholders():
    placeholders = get_answer_placeholders()
    if placeholders[1].replace("\'", "\"") == '"hot "' and placeholders[0].replace(" ", "").replace("\'", "\"") == '"grass"+"hopper"' \
            and placeholders[2].replace(" ", "").replace("\'", "\"") == '"l"+"a"+"d"+"y"+"b"+"u"+"g"':
        passed()
    else:
        failed()
示例#21
0
def test_answer_placeholders():
    placeholders = get_answer_placeholders()
    placeholder = placeholders[0]
    if placeholder == "root":
        passed()
    else:
        failed()
示例#22
0
def test_answer_placeholders():
    placeholders = get_answer_placeholders()
    placeholder = placeholders[0]
    if placeholder == "print":  # TODO: your condition here
        passed()
    else:
        failed("Use the print luke.")
示例#23
0
def test_answer_placeholders():
    placeholders = get_answer_placeholders()
    not_correct = placeholders[0]
    while_condition = placeholders[1]
    user_input = placeholders[2]
    equals_to = placeholders[3]
    less_than = placeholders[4]
    if not_correct == "True":  # TODO: your condition here
        passed()
    else:
        failed("When we start, should the user be correct or incorrect?")
    if while_condition == "not_correct":
        passed()
    else:
        failed("We want the loop to keep running when what is True?")
    if "raw_input(" in user_input:
        passed()
    else:
        failed("This is where we ask the user to guess the number")
    if "==" in equals_to:
        passed()
    else:
        failed("When does the user win?")
    if "<" in less_than:
        passed()
    else:
        failed("When should we say higher than?")
示例#24
0
def test_answer_placeholders():
    placeholders = get_answer_placeholders()
    placeholder = placeholders[0]
    if placeholder == "logger.addHandler(logging.NullHandler())":
        passed()
    else:
        failed()
示例#25
0
def test_outputs():

    outputs = get_file_output()
    if len(outputs) >= 3 and outputs[-3:] == ['IT IS STILL SNOWING', 'SHOULD WE GO SLEDDING', 'I CANNOT FIND MY BOOTS']:
        passed()
    else:
        failed(message='Please try again.')
示例#26
0
def test_answer_placeholders():
    placeholders = get_answer_placeholders()
    placeholder = placeholders[0].replace('"', "'")
    if placeholder == "filename=log_filename":
        passed()
    else:
        failed()
示例#27
0
def test_window():
    windows = get_answer_placeholders()

    if windows[0] == "%d":
        passed()
    else:
        failed("Use %d special symbol")
示例#28
0
def test_answer_placeholders():
    placeholders = get_answer_placeholders()
    placeholder = placeholders[0]
    if placeholder == "False" or placeholder == '0':
        passed()
    else:
        failed()
示例#29
0
def test_answer_placeholders():
    placeholders = get_answer_placeholders()
    placeholder = placeholders[0]
    if "^$" in placeholder:
        passed()
    else:
        failed("Use '^$' to match empty string")
示例#30
0
def test_answer_placeholders():
    placeholders = get_answer_placeholders()
    placeholder = placeholders[0].replace('"', "'")
    if placeholder.startswith("logger.exception(") and placeholder.find("'") != -1:
        passed()
    else:
        failed("That is not correct. Be sure to call exception() with a string argument.")
示例#31
0
def check_position():
    task = import_task_file()
    if task.board.servos[0].position == -0.25:
        return passed()
    return failed("Position incorrect")
示例#32
0
from maximum_salary import largest_number


def reference(numbers):
    numbers = list(map(str, numbers))

    for _ in numbers:
        for i in range(len(numbers) - 1):
            if numbers[i] + numbers[i + 1] < numbers[i + 1] + numbers[i]:
                t = numbers[i]
                numbers[i] = numbers[i + 1]
                numbers[i + 1] = t

    return int("".join(numbers))


if __name__ == '__main__':
    run_common_tests()
    check_tests_pass("maximum_salary_unit_tests.py")

    all_tests_passed = True
    for numbers in [[2, 21, 23, 211, 213, 231, 232],
                    [56, 5, 6, 556, 566, 666, 665, 656]]:
        if reference(numbers) != largest_number(numbers):
            all_tests_passed = False
            failed("Wrong answer for n={}".format(numbers))
            break

    if all_tests_passed:
        passed()
示例#33
0
def test_window():
    window = get_answer_placeholders()[0]
    if "square" in window and "def " in window:
        passed()
    else:
        failed("Name your function 'square'")
示例#34
0
def test_column():
    window = get_answer_placeholders()[0]
    if ":" in window:
        passed()
    else:
        failed("Don't forget a colon at the end of the statement")
示例#35
0
from test_helper import run_common_tests, failed, passed, check_tests_pass
from money_change_again import change, change_naive
from random import randint

if __name__ == '__main__':
    run_common_tests()
    check_tests_pass("money_change_again_unit_tests.py")

    all_tests_passed = True

    for _ in range(20):
        money = randint(1, 100)
        if change_naive(money) != change(money):
            all_tests_passed = False
            failed("Wrong answer for money={}".format(money))
            break

    if all_tests_passed:
        passed()
示例#36
0
def test_task_window():
    window = get_answer_placeholders()[0]
    if "anderer Wert" == window:
        failed("Du solltest die Variable 'gruesse' neu definieren")
    else:
        passed()
示例#37
0
def test_window():
    window = get_answer_placeholders()[0]
    if "int" in window and "float_number" in window:
        passed()
    else:
        failed("Use the int() function")
def test_remainder():
    file = import_task_file()
    if file.remainder == 1.0:
        passed()
    else:
        failed("Wrong remainder")
示例#39
0
def check_integer_truthiness_tests():
    task_module = import_task_file()
    TestIntegerTruthiness = inspect_assertions(
        task_module.TestIntegerTruthiness)
    test_result = run_test_case_tests(TestIntegerTruthiness)

    if not test_result.wasSuccessful():
        failed("Some of the TestIntegerTruthiness tests failed!")

    placeholder_windows = get_answer_placeholders()[0:3]
    test_zero_window, test_one_window, test_other_value_window = placeholder_windows

    # check test_zero
    n_assertions = TestIntegerTruthiness.get_test_method_total_call_count(
        "test_zero")
    test_name = "TestIntegerTruthiness.test_zero"
    if n_assertions > 1:
        failed(name=test_name, message="must use only one assertion")
    elif n_assertions == 0:
        failed(name=test_name, message="must use an assertion")
    elif unittest.mock.call(0) in TestIntegerTruthiness.per_method_counters[
            "test_zero"]["assertFalse"].call_args_list:
        passed(name=test_name)
    else:
        failed(name=test_name)

    # check test_one
    n_assertions = TestIntegerTruthiness.get_test_method_total_call_count(
        "test_one")
    test_name = "TestIntegerTruthiness.test_one"
    if n_assertions > 1:
        failed(name=test_name, message="must use only one assertion")
    elif n_assertions == 0:
        failed(name=test_name, message="must use an assertion")
    elif unittest.mock.call(1) in TestIntegerTruthiness.per_method_counters[
            "test_one"]["assertTrue"].call_args_list:
        passed(name=test_name)
    else:
        failed(name=test_name)

    # check test_other_value
    wrapped_assertTrue = TestIntegerTruthiness.per_method_counters[
        "test_other_value"]["assertTrue"]
    n_assertions = TestIntegerTruthiness.get_test_method_total_call_count(
        "test_other_value")
    test_name = "TestIntegerTruthiness.test_other_value"
    if n_assertions > 1:
        failed(name=test_name, message="must use only one assertion")
    elif n_assertions == 0:
        failed(name=test_name, message="must use an assertion")
    elif ("self.assertTrue" in test_other_value_window
          and wrapped_assertTrue.call_count > 0
          and isinstance(wrapped_assertTrue.call_args[0][0], int)
          and wrapped_assertTrue.call_args[0][0] not in {0, 1}):
        passed(name=test_name)
    else:
        failed(name=test_name)
def test_division():
    file = import_task_file()
    if file.result == 4.5:
        passed()
    else:
        failed("Wrong result")
示例#41
0
文件: tests.py 项目: MeryemB/L1MEO
def test_moyenne():
    file = import_task_file()
    if file.moyenne == 14.166666666666666:
        passed()
    else:
        failed("Résultat erroné!")
示例#42
0
def check_test_container_class_assertion_methods():
    window1, window2 = get_answer_placeholders()[4:6]
    if window1 == 'False' and window2 == 'True':
        passed()
    else:
        failed()
示例#43
0
    def testAnswer6(self):
        self.assertRegex(helper.answers[5], helper.re.argsRegex("1"))

    def testAnswer7(self):
        self.assertEqual(helper.answers[6], "if")

    def testAnswer8(self):
        self.assertRegex(helper.answers[7], "Ja|ja")

    def testAnswer9(self):
        self.assertEqual(helper.answers[8], "y")

    def testAnswer10(self):
        self.assertRegex(helper.answers[9],
                         helper.re.expressionToRegex("10 >= y"))

    def testAnswer11(self):
        self.assertEqual(helper.answers[10], "False")


if __name__ == '__main__':
    suite = unittest.TestLoader().loadTestsFromTestCase(
        testCaseClass=varAanmaken)
    res = unittest.TextTestRunner().run(suite)
    if res.wasSuccessful():
        passed("Congratulations")
    else:
        for el in res.failures:
            failed(f"There is an error in " + str(el[0])[4:12])
示例#44
0
def conditional_passed_or_failed(condition, name):
    if condition:
        passed(name=name)
    else:
        failed(name=name)
示例#45
0
                    d[i + 1][j + 1][k + 1] = max(d[i + 1][j + 1][k + 1],
                                                 d[i][j][k] + 1)
    return d[len(a)][len(b)][len(c)]


if __name__ == '__main__':
    run_common_tests()
    check_tests_pass("lcs3_unit_tests.py")

    seed(239)

    all_tests_passed = True

    for _ in range(10):
        for n in (3, 5, 20, 10):
            for m in (2, 3, 4, 10, 100):
                lena = randint(1, n)
                lenb = randint(1, n)
                lenc = randint(1, n)
                a = [randint(1, m) for _ in range(lena)]
                b = [randint(1, m) for _ in range(lenb)]
                c = [randint(1, m) for _ in range(lenc)]

                if lcs3(a, b, c) != ref(a, b, c):
                    all_tests_passed = False
                    failed("Wrong answer: {}; {}; {}".format(a, b, c))
                    break

    if all_tests_passed:
        passed()
示例#46
0
文件: tests.py 项目: MeryemB/L1MEO
def test_var_used():
    window = get_answer_placeholders()[0]
    if "note1" in window and "note2" in window and "note3" in window:
        passed()
    else:
        failed("Veuillez affecter les variables note1, note2 et note3 par leurs valeurs")
def test_value():
    file = import_task_file()
    if hasattr(file, "p_letter") and file.p_letter == "P":
        passed()
    else:
        failed("String index starts at 0.")
示例#48
0
def test_answer_placeholders():
    placeholders = get_answer_placeholders()
    phi = placeholders[0]
    stri = "Answer 1"
    if len(phi) > 50:
        failed(stri + " please keep length to less than 50 characters. Your answer '" + phi + "' is " + str(len(phi)) + " characters.")
        return False
    answer = eval("(" + phi + ")", {}, {})
    print(answer)
    if not isinstance(answer, tuple):
        failed(stri + " is not a tuple. It is a " + escape(str(type(answer))) + ". Your answer '" + phi + "'")
        return False
    print(str(len(answer)))
    if len(answer) != 2:
        failed(stri + " is supposed to contain 2 elements but has " + str(len(answer)) + ". Your answer '" + phi + "'")
        return False
    if not isinstance(answer[0],str):
        failed(stri + " first element is not a string. It is " + repr(answer[0]) + " which has type " + escape(str(type(answer[0]))))
        return False
    print(str(type(answer[1])))
    if not isinstance(answer[1],str):
        failed(stri + " second element is not a string. It is " + repr(answer[1]) + " which has type " + escape(str(type(answer[1]))))
        return False
    phi = placeholders[1]
    stri = "Answer 2"
    if len(phi) > 50:
        failed(stri + " please keep length to less than 50 characters. Your answer '" + phi + "' is " + str(len(phi)) + " characters.")
        return False
    answer = eval("(" + phi + ")", {}, {})
    if not isinstance(answer, tuple):
        failed(stri + " is not a tuple. It is a " + escape(str(type(answer))) + ". Your answer '" + phi + "'")
        return False
    if len(answer) != 3:
        failed(stri + " is supposed to contain 3 elements but has " + str(len(answer)) + ". Your answer '" + phi + "'")
        return False
    if not isinstance(answer[0],str):
        failed(stri + " first element is not a string. It is " + repr(answer[0]) + " which has type " + escape(str(type(answer[0]))))
        return False
    if not isinstance(answer[1],int):
        failed(stri + " second element is not an int. It is " + repr(answer[1]) + " which has type " + escape(str(type(answer[1]))))
        return False
    if not isinstance(answer[2],float):
        failed(stri + " third element is not a float. It is " + repr(answer[2]) + " which has type " + escape(str(type(answer[2]))))
        return False
    if not test_string(placeholders, 2, "1"): return False
    if not test_string(placeholders, 3, "5"): return False
    if not test_exec(placeholders, 4, "x, y, z = t1",[{'t1':(15,6,1234)}]): return False
    passed()
    return True
示例#49
0
def test_window():
    window = get_answer_placeholders()[0]
    if "my_object" in window and "variable1" in window:
        passed()
    else:
        failed("Access 'variable1' using my_object.variable1")
def test_window():
    window = get_answer_placeholders()[0]
    if "[" in window and "0" in window and "]" in window:
        passed()
    else:
        failed("Use indexing")
示例#51
0
def test_window():
    window = get_answer_placeholders()[0]
    if "for " in window:
        passed()
    else:
        failed("Use a for loop to iterate over the hello_world string")
示例#52
0
from test_helper import run_common_tests, failed, passed, get_answer_placeholders
from task import *

if __name__ == '__main__':
    n = 10
    arr1 = "0 0 0 0 1 0 1 0 1"
    arr2 = "5 10 17 6 2 1 3 2 4"
    if maxVahed(n, arr1, arr2) != 20:
        failed("Wrong Answer")

    n = 6
    arr1 = "0 0 1 0 1"
    arr2 = "10 12 2 1 3"

    if maxVahed(n, arr1, arr2) != 13:
        failed("Wrong Answer")
def test_window():
    window = get_answer_placeholders()[0]
    if "print" in window and "line" in window:
        passed()
    else:
        failed("Use print function")
示例#54
0
def test_value():
    file = import_task_file()
    if hasattr(file, "length") and file.length == 13:
        passed()
    else:
        failed("Count again")
示例#55
0
def test_window3():
    window = get_answer_placeholders()[2]
    if "tmp_var" in window:
        passed()
    else:
        failed("Update a with tmp_var")
示例#56
0
from test_helper import run_common_tests, failed, passed, get_answer_placeholders
from random import shuffle
from random import randint
from task import data_structure as func
from task_copy import data_structure as func_judge


def test_generator(n):
    li = []
    for i in range(n):
        kind = randint(1, 2)
        max_range = 10000
        if kind == 1:
            li.append((1, randint(1, max_range), randint(1, max_range)))
        else:
            li.append((2, randint(1, max_range)))
    return li
if __name__ == '__main__':
    test_nums = [10, 10, 100, 100, 10000]
    for test_num in test_nums:
        li = test_generator(test_num)
        user_li = func(li[0:len(li)])
        judge_li = func_judge(li[0:len(li)])
        if user_li != judge_li:
            failed("Wrong Answer! Input: " + str(li) +
                   " Your Answer: " + str(user_li) +
                   " Expected Answer: " + str(judge_li))
    print("PASS")


示例#57
0
def test_window():
    window = get_answer_placeholders()[0]
    if "from " in window:
        passed()
    else:
        failed("Benutze hello_world importiert aus my_module")
示例#58
0
def test_window1():
    window = get_answer_placeholders()[0]
    if "1" in window:
        passed()
    else:
        failed("Initialize b with 1")
示例#59
0
from test_helper import run_common_tests, failed, passed, check_tests_pass
from closest_points import minimum_distance_squared, minimum_distance_squared_naive, Point
from math import fabs
from random import randint

if __name__ == '__main__':
    run_common_tests()
    check_tests_pass("closest_points_unit_tests.py")

    all_tests_passed = True

    for points in ([Point(-10**9, -10**9),
                    Point(10**9,
                          10**9)], [Point(i, i + 1) for i in range(100)],
                   [Point(randint(1, 10), randint(1, 10)) for _ in range(5)],
                   [Point(randint(1, 10), randint(1, 10))
                    for _ in range(500)]):
        if fabs(
                minimum_distance_squared(points) -
                minimum_distance_squared_naive(points)) > 1e-03:
            all_tests_passed = False
            failed("Wrong answer for points={}".format(points))
            break

    if all_tests_passed:
        passed()
示例#60
0
def test_window2():
    window = get_answer_placeholders()[1]
    if "b" in window and "a" in window:
        passed()
    else:
        failed("Update b with a + b")