Exemplo n.º 1
0
def test_windows():
    windows = get_task_windows()

    if "number" in windows[0] and "number" in windows[1]:
        passed()
    else:
        failed("Use % operator")
Exemplo n.º 2
0
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)")
Exemplo n.º 3
0
def test_published_date():
    placeholders = get_answer_placeholders()
    placeholder = placeholders[2]
    if "published_date" in placeholder:
        passed()
    else:
        failed("Define published_date variable")
Exemplo n.º 4
0
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")
Exemplo n.º 5
0
def test_answer_placeholders():
    placeholders = get_answer_placeholders()
    placeholder = placeholders[0]
    if placeholder == "models.Model":
        passed()
    else:
        failed("Use models.Model as an ancestor")
Exemplo n.º 6
0
def test_title():
    placeholders = get_answer_placeholders()
    placeholder = placeholders[1]
    if "title" in placeholder:
        passed()
    else:
        failed("Define title variable")
Exemplo n.º 7
0
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")
Exemplo n.º 8
0
def test_window():
    window = get_answer_placeholders()[0]

    if " in " in window:
        passed()
    else:
        failed("Use 'in' operator for this check")
Exemplo n.º 9
0
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'")
Exemplo n.º 10
0
def test_windows():
    windows = get_answer_placeholders()

    if "number" in windows[0] and "number" in windows[1]:
        passed()
    else:
        failed("Use % operator")
Exemplo n.º 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.')
Exemplo n.º 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")
Exemplo n.º 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")
Exemplo n.º 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)")
Exemplo n.º 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")
Exemplo n.º 16
0
def test_value():
    file = import_task_file()

    if file.greetings == "greetings":
        failed("You should assign different value to the variable")
    else:
        passed()
Exemplo n.º 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()
Exemplo n.º 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.')
Exemplo n.º 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()
Exemplo n.º 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()
Exemplo n.º 21
0
def test_answer_placeholders():
    placeholders = get_answer_placeholders()
    placeholder = placeholders[0]
    if placeholder == "root":
        passed()
    else:
        failed()
Exemplo n.º 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.")
Exemplo n.º 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?")
Exemplo n.º 24
0
def test_answer_placeholders():
    placeholders = get_answer_placeholders()
    placeholder = placeholders[0]
    if placeholder == "logger.addHandler(logging.NullHandler())":
        passed()
    else:
        failed()
Exemplo n.º 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.')
Exemplo n.º 26
0
def test_answer_placeholders():
    placeholders = get_answer_placeholders()
    placeholder = placeholders[0].replace('"', "'")
    if placeholder == "filename=log_filename":
        passed()
    else:
        failed()
Exemplo n.º 27
0
def test_window():
    windows = get_answer_placeholders()

    if windows[0] == "%d":
        passed()
    else:
        failed("Use %d special symbol")
Exemplo n.º 28
0
def test_answer_placeholders():
    placeholders = get_answer_placeholders()
    placeholder = placeholders[0]
    if placeholder == "False" or placeholder == '0':
        passed()
    else:
        failed()
Exemplo n.º 29
0
def test_answer_placeholders():
    placeholders = get_answer_placeholders()
    placeholder = placeholders[0]
    if "^$" in placeholder:
        passed()
    else:
        failed("Use '^$' to match empty string")
Exemplo n.º 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.")
Exemplo n.º 31
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()
Exemplo n.º 32
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")
Exemplo n.º 33
0
def test_window():
    window = get_answer_placeholders()[0]
    if "print" in window and "line" in window:
        passed()
    else:
        failed("Use print function")
Exemplo n.º 34
0
def test_window1():
    window = get_answer_placeholders()[0]
    if "1" in window:
        passed()
    else:
        failed("Initialize b with 1")
Exemplo n.º 35
0
def test_window3():
    window = get_answer_placeholders()[2]
    if "tmp_var" in window:
        passed()
    else:
        failed("Update a with tmp_var")
Exemplo n.º 36
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")
Exemplo n.º 37
0
def test_window():
    window = get_answer_placeholders()[0]
    if "from " in window:
        passed()
    else:
        failed("Benutze hello_world importiert aus my_module")
Exemplo n.º 38
0
def test_value():
    output = get_file_output()
    if "[4, 9, 16]" in output:
        passed()
    else:
        failed("Use list slicing lst[index1:index2]")
Exemplo n.º 39
0
        self.assertRegex(helper.answers[1], "list|List|array|Array")

    def testAnswer3(self):
        self.assertEqual(helper.answers[2], "emptyArray")

    def testAnswer4(self):
        self.assertRegex(helper.answers[3], helper.re.listRegex("\"first\"", "\"second\""))

    def testAnswer5(self):
        self.assertRegex(helper.answers[4], helper.re.listRegex("1", "2", "3", "1"))

    def testAnswer6(self):
        self.assertRegex(helper.answers[5], helper.re.listRegex("\"1\"", "\"2\"", "\"3\"", "\"4\""))

    def testAnswer7(self):
        self.assertRegex(helper.answers[6], helper.re.listRegex("13", "1", "2", "3", "1"))


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])




Exemplo n.º 40
0
def test_window():
    window = get_answer_placeholders()[0]
    if "Car" in window and "(" in window and ")" in window:
        passed()
    else:
        failed("Create a new car using Car()")
Exemplo n.º 41
0
def test_window2():
    window = get_answer_placeholders("read_file.py")[1]
    if "f1" in window and "readline" in window:
        passed()
    else:
        failed("Use 'readline' method")
Exemplo n.º 42
0
def test_window():
    window = get_answer_placeholders()[0]
    if "squares" in window and "[" in window and "]" in window and ":" in window:
        passed()
    else:
        failed("Use list slicing lst[index1:index2]")
Exemplo n.º 43
0
def test_window():
    window = get_answer_placeholders()[0]
    if "=" in window:
        passed()
    else:
        failed("Füge einen Standardwert hinzu")
Exemplo n.º 44
0
def test_window3():
    window = get_answer_placeholders("read_file.py")[2]
    if "f1" in window and "close" in window and "(" in window:
        passed()
    else:
        failed("Call 'close' method")
Exemplo n.º 45
0
def test_answer_placeholders():
    placeholders = get_answer_placeholders()
    list_wool = [
        "white", "grey", "dark_grey", "black", "blue", "cyan", "green",
        "dark_green", "yellow", "orange", "brown", "red", "pink", "magenta",
        "violet"
    ]
    if not test_string_in(placeholders, 0, list_wool): return False
    if not test_string_in(placeholders, 1, list_wool): return False
    if not test_string(placeholders, 2, '9'): return False
    if not test_string(placeholders, 3, '9'): return False
    if not test_eval(placeholders, 4, 'cx - width // 2', [{
            'cx': 100,
            'width': 9
    }, {
            'cx': 110,
            'width': 21
    }]):
        return False
    if not test_eval(placeholders, 5, 'cy - height // 2', [{
            'cy': 14,
            'height': 9
    }, {
            'cy': 15,
            'height': 21
    }]):
        return False
    list_var = [x.strip() for x in placeholders[6].strip().split(",")]
    if len(list_var) != 2 and len(list_var) != 3:
        failed(
            "Wrong number of arguments in answer 7. Should be 2 (or 3). You have "
            + str(len(list_var))) + str(list_var)
        return False
    if not test_eval_phi(list_var[0], "First argument in answer 7", 'y1',
                         [{
                             'y1': 28
                         }, {
                             'y1': 36
                         }]):
        return False
    if not test_eval_phi(list_var[1], "Second argument in answer 7", 'y2',
                         [{
                             'y2': 28
                         }, {
                             'y2': 36
                         }]):
        return False
    list_var = [x.strip() for x in placeholders[7].strip().split(",")]
    if len(list_var) != 2 and len(list_var) != 3:
        failed(
            "Wrong number of arguments in answer 8. Should be 2 (or 3). You have "
            + str(len(list_var)))
        return False
    if not test_eval_phi(list_var[0], "First argument in answer 8", 'x1',
                         [{
                             'x1': 96
                         }, {
                             'x1': 104
                         }]):
        return False
    if not test_eval_phi(list_var[1], "Second argument in answer 8", 'x2',
                         [{
                             'x2': 96
                         }, {
                             'x2': 104
                         }]):
        return False
    # Can't test 8 because may have formula over several lines
    #if not test_formula(placeholders, 6, 'colours[(y+x)%2]')
    passed()
    return True
Exemplo n.º 46
0
def test_window():
    window = get_answer_placeholders()[0]
    if "my_object" in window and "variable1" in window:
        passed()
    else:
        failed("Benutze my_object.variable1 für den Zugriff")
Exemplo n.º 47
0
def test_negative_index():
    window = get_answer_placeholders()[0]
    if "-" in window:
        passed()
    else:
        failed("Use negative index")
Exemplo n.º 48
0
def test_window_names():
    window = get_answer_placeholders()[0]
    if "subject" in window and "name" in window:
        passed()
    else:
        failed("Füge einen Standardwert hinzu")
Exemplo n.º 49
0
def test_column():
    window = get_answer_placeholders()[0]
    if ":" in window:
        passed()
    else:
        failed("Vergesse nicht : am Ende")
Exemplo n.º 50
0
def test_value():
    file = import_task_file()
    if hasattr(file, "exclamation") and file.exclamation == "!":
        passed()
    else:
        failed("Use -1 index to get the last character")
Exemplo n.º 51
0
def test_columns():
    windows = get_answer_placeholders()
    if ":" in windows[0] and ":" in windows[1]:
        passed()
    else:
        failed("Don't forget a colon at the end")
Exemplo n.º 52
0
def test_window():
    window = get_answer_placeholders()[0]
    if "square" in window and "def " in window:
        passed()
    else:
        failed("Nenne die Funktion square")
Exemplo n.º 53
0
def test_window():
    window = get_answer_placeholders()[0]
    if "len(" in window:
        passed()
    else:
        failed("Use len() function")
Exemplo n.º 54
0
def test_window():
    window = get_answer_placeholders()[0]
    if "prime" in window and "for " in window and "primes" in window and " in " in window:
        passed()
    else:
        failed("Use for loop to iterate over 'primes'")
Exemplo n.º 55
0
def test_window():
    window = get_answer_placeholders()[0]
    if "==" in window:
        passed()
    else:
        failed("Benutze ==")
Exemplo n.º 56
0
def test_window2():
    window = get_answer_placeholders()[1]
    if "else" in window:
        passed()
    else:
        failed("Use else keyword")
Exemplo n.º 57
0
def test_window():
    window = get_answer_placeholders()[0]
    if "name" in window and "John" in window and "and" in window and "23" in window:
        passed()
    else:
        failed("Benutze das and-Schlüsselwort und den != Operator")
Exemplo n.º 58
0
def test_value():
    file = import_task_file()
    if not file.is_equal:
        passed()
    else:
        failed("Benutze ==")
Exemplo n.º 59
0
def test_value():
    file = import_task_file()
    if file.length == 13:
        passed()
    else:
        failed("Count again")
Exemplo n.º 60
0
def test_window():
    window = get_answer_placeholders()[0]
    if "phone_book" in window and "Jane" in window:
        passed()
    else:
        failed("Use indexing e.g. dct[key]")