from test_helper import run_common_tests, import_task_file, passed, failed, get_answer_placeholders def test_value(): file = import_task_file() if "dinosaur" in file.animals and not "dino" in file.animals: passed() else: failed("Replace 'dino' with 'dinosaur'") def test_window(): window = get_answer_placeholders()[0] if "animals" in window and "[" in window: passed() else: failed("Replace 'dino' with 'dinosaur'") if __name__ == '__main__': run_common_tests("Use indexing and assignment") test_value() test_window()
from test_helper import run_common_tests, passed, failed, import_task_file, get_answer_placeholders def test_value(): file = import_task_file() if file.is_greater: passed() else: failed("Use > operator") def test_window(): window = get_answer_placeholders()[0] if ">" in window and ">=" not in window: passed() else: failed("Use > operator") if __name__ == '__main__': run_common_tests("You should modify the file") test_value() test_window()
from test_helper import run_common_tests, failed, passed, import_task_file, get_answer_placeholders def test_value(): file = import_task_file() if hasattr(file, "animals") and not file.animals: passed() else: failed("Clear animals list") def test_window(): window = get_answer_placeholders()[0] if "animals" in window: passed() else: failed("Clear animals list") if __name__ == '__main__': run_common_tests("Use assignment to empty list") test_window() test_value()
from test_helper import run_common_tests if __name__ == '__main__': run_common_tests("您必须输入新的注释")
def run_patched_tests(): run_common_tests() test_building()
from test_helper import run_common_tests, failed, passed, import_task_file, get_answer_placeholders def test_task_window(): window = get_answer_placeholders()[0] if window == "another value": failed("You should redefine the variable 'greetings'") else: passed() def test_value(): file = import_task_file() if file.greetings == "greetings": failed("You should assign a different value to the variable") else: passed() if __name__ == '__main__': test_task_window() run_common_tests("You should redefine the variable 'greetings'") test_value()
def run_patched_tests(): run_common_tests()
from test_helper import run_common_tests, passed, failed, get_answer_placeholders 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") if __name__ == '__main__': run_common_tests("Benutze das and-Schlüsselwort und den != Operator") test_window()
from test_helper import run_common_tests if __name__ == '__main__': run_common_tests("You should type new comment")
from test_helper import run_common_tests, get_answer_placeholders, passed, failed, get_file_output, test_file_importable def test_value(): output = get_file_output()[1] if "[4, 9, 16]" in output: passed() else: failed("Benutze die Listenaufteilung lst[index1:index2]") def test_window(): window = get_answer_placeholders()[0] if "squares" in window and "[" in window and "]" in window and ":" in window: passed() else: failed("Benutze die Listenaufteilung lst[index1:index2]") if __name__ == '__main__': test_file_importable() test_value() test_window() run_common_tests("Benutze die Listenaufteilung lst[index1:index2]")
from test_helper import run_common_tests, passed, failed, get_answer_placeholders def test_window(): window = get_answer_placeholders()[0] if "len(" in window: passed() else: failed("Benutze die Funktion len()") if __name__ == '__main__': run_common_tests("Benutze die Funktion len()") test_window()
from test_helper import run_common_tests, failed, passed, get_answer_placeholders def test_window(): window = get_answer_placeholders()[0] if "grocery_dict" in window and " in " in window: passed() else: failed("Benutze das in-Schlüsselwort") def test_fish(): window = get_answer_placeholders()[0] if "fish" in window: passed() else: failed("Prüfe ob die grocery_dict keys fish enthalten") if __name__ == '__main__': run_common_tests("Benutze das in-Schlüsselwort") test_window() test_fish()
from test_helper import run_common_tests, get_task_windows, passed, failed def test_window(): window = get_task_windows()[0] if "phone_book" in window and "Jane" in window: passed() else: failed("Use indexing e.g. dct[key]") if __name__ == '__main__': run_common_tests("Use indexing e.g. dct[key]") test_window()
from test_helper import run_common_tests, failed, passed, import_task_file, get_answer_placeholders def test_value(): file = import_task_file() if not file.animals: passed() else: failed("Clear animals list") def test_window(): window = get_answer_placeholders()[0] if "animals" in window: passed() else: failed("Clear animals list") if __name__ == '__main__': run_common_tests("Use assignment to empty list") test_window() test_value()
from test_helper import run_common_tests, get_answer_placeholders, passed, failed 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]") if __name__ == '__main__': run_common_tests("Use indexing e.g. dct[key]") test_window()
def test_ASCII(): windows = get_answer_placeholders() for window in windows: all_ascii = all(ord(c) < 128 for c in window) if not all_ascii: failed("Please use only English characters this time.") return passed() def test_is_alpha(): window = get_answer_placeholders()[0] is_multiline = window.find("\n") if is_multiline != -1: window = window[:is_multiline-1] splitted = window.split() for s in splitted: if not s.isalpha(): failed("Please use only English characters this time.") return passed() if __name__ == '__main__': test_ASCII() run_common_tests("You should enter your name") test_is_alpha()
if "John" in window and "if " in window: if "==" in window or "is" in window: passed() else: failed("Check equality") else: failed("Use if keyword") def test_window2(): window = get_answer_placeholders()[1] if "else" in window: passed() else: failed("Use else keyword") 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") if __name__ == '__main__': run_common_tests("Use if/else keywords") test_window1() test_window2() test_columns()
def run_patched_tests(): run_common_tests() # test_answer_placeholders() # TODO: uncomment test call test_building()
from test_helper import run_common_tests, get_answer_placeholders, passed, failed, get_file_output, test_file_importable def test_value(): output = get_file_output() if "[4, 9, 16]" in output: passed() else: failed("Use list slicing lst[index1:index2]") 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]") if __name__ == '__main__': test_file_importable() test_value() test_window() run_common_tests("Use list slicing lst[index1:index2]")
from test_helper import run_common_tests, failed, passed, get_answer_placeholders def test_answer_placeholders(): placeholders = get_answer_placeholders() if placeholders[0] != "__new__": # TODO: your condition here failed("Error! method for creation instance is wrong!") if placeholders[1] != "hasattr": # TODO: your condition here failed("Error! func for checking is wrong!") if placeholders[2] != "super": # TODO: your condition here failed("Error! func for getting parents obj is wrong!") if placeholders[3] != "__init__": # TODO: your condition here failed("Error! method for initializing is wrong!") if placeholders[4] != "id" or placeholders[5] != "id": # TODO: your condition here failed("Error! func for getting is wrong!") if placeholders[0] == "__new__" and placeholders[1] == "hasattr" and\ placeholders[2] == "super" and placeholders[3] == "__init__" and placeholders[4] == placeholders[5] == "id": passed("Congratulations!!! Now you know how to create singleton!") if __name__ == '__main__': run_common_tests() test_answer_placeholders() # TODO: uncomment test call
from test_helper import run_common_tests, get_task_windows, passed, failed, get_file_output def test_value(): output = get_file_output() if "[4, 9, 16]" in output: passed() else: failed("Use list slicing lst[index1:index2]") def test_window(): window = get_task_windows()[0] if "squares" in window and "[" in window and "]" in window and ":" in window: passed() else: failed("Use list slicing lst[index1:index2]") if __name__ == '__main__': test_value() test_window() run_common_tests("Use list slicing lst[index1:index2]")
from test_helper import run_common_tests, passed, failed, get_task_windows def test_window(): window = get_task_windows()[0] if "name" in window and "John" in window and "and" in window and "23" in window: passed() else: failed("Use and keyword and != operator") if __name__ == '__main__': run_common_tests("Use 'and' keyword and != operator") test_window()
from test_helper import run_common_tests if __name__ == '__main__': run_common_tests("Du solltest einen neuen Kommentar hinzufügen")
from test_helper import run_common_tests, passed, failed, get_answer_placeholders def test_window(): window = get_answer_placeholders()[0] if "len(" in window: passed() else: failed("Use len() function") if __name__ == '__main__': run_common_tests("Use len() function") test_window()
def test_ASCII(): windows = get_answer_placeholders() for window in windows: all_ascii = all(ord(c) < 256 for c in window) if not all_ascii: failed("Benutze bitte keine Sonderzeichen.") return passed() def test_is_alpha(): window = get_answer_placeholders()[0] is_multiline = window.find("\n") if is_multiline != -1: window = window[:is_multiline - 1] splitted = window.split() for s in splitted: if not s.isalpha(): failed("Benutze bitte keine Sonderzeichen.") return passed() if __name__ == '__main__': test_ASCII() run_common_tests("Du solltest deinen Namen eingeben") test_is_alpha()
from test_helper import run_common_tests, failed, passed, get_task_windows def test_window(): window = get_task_windows()[0] if "grocery_dict" in window and " in " in window and "fish" in window: passed() else: failed("Use in keyword") if __name__ == '__main__': run_common_tests("Use in keyword") test_window()
from test_helper import run_common_tests, failed, passed, import_task_file, get_answer_placeholders def test_task_window(): window = get_answer_placeholders()[0] if "anderer Wert" == window: failed("Du solltest die Variable 'gruesse' neu definieren") else: passed() def test_value(): file = import_task_file() if file.greetings == "Grüße": failed("Du solltest der Variable einen anderen Wert zuweisen.") else: passed() if __name__ == '__main__': test_task_window() run_common_tests("Du solltest die Variable 'gruesse' neu definieren") test_value()
from test_helper import run_common_tests, failed, passed, import_task_file def test_value(): file = import_task_file() if file.greetings == "greetings": failed("You should assign different value to the variable") else: passed() if __name__ == '__main__': test_value() run_common_tests("You should redefine variable 'greetings'")
from test_helper import run_common_tests, failed, passed, get_answer_placeholders def test_initial(): window = get_answer_placeholders()[0] if window == "type your name": failed("You should modify the file") else: passed() if __name__ == '__main__': run_common_tests("You should enter your name") test_initial()
from test_helper import run_common_tests, passed, failed, get_answer_placeholders 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("Use and keyword and != operator") if __name__ == '__main__': run_common_tests("Use 'and' keyword and != operator") test_window()
def run_patched_tests(): if test_answer_placeholders(): run_common_tests() test_building()
from test_helper import run_common_tests, failed, passed, get_answer_placeholders def test_window(): window = get_answer_placeholders()[0] if "grocery_dict" in window and " in " in window: passed() else: failed("Use in keyword") def test_fish(): window = get_answer_placeholders()[0] if "fish" in window: passed() else: failed("Check if grocery_dict keys contain fish") if __name__ == '__main__': run_common_tests("Use in keyword") test_window() test_fish()
from test_helper import run_common_tests, failed, passed, get_task_windows def test_ASCII(): windows = get_task_windows() for window in windows: all_ascii = all(ord(c) < 128 for c in window) if not all_ascii: failed("Please, use only english characters for this time.") return passed() def test_is_alpha(): window = get_task_windows()[0] splitted = window.split() for s in splitted: if not s.isalpha(): failed("Please, use only english characters for this time.") return passed() if __name__ == '__main__': test_ASCII() run_common_tests("You should type your name") test_is_alpha()
from test_helper import run_common_tests, import_task_file, passed, failed, get_answer_placeholders def test_value(): file = import_task_file() if hasattr(file, "animals" ) and "dinosaur" in file.animals and not "dino" in file.animals: passed() else: failed("Ersetze 'dino' durch 'dinosaur'") def test_window(): window = get_answer_placeholders()[0] if "animals" in window and "[" in window: passed() else: failed("Ersetze 'dino' durch 'dinosaur'") if __name__ == '__main__': run_common_tests("Benutze die Indexierung und Zuweisung") test_value() test_window()
from test_helper import run_common_tests, passed, failed, import_task_file, get_answer_placeholders def test_division(): file = import_task_file() if file.division == 4.5: passed() else: failed("Use / operator") def test_remainder(): file = import_task_file() if file.remainder == 1.0: passed() else: failed("Use % operator") def test_windows(): windows = get_answer_placeholders() if "number" in windows[0] and "number" in windows[1]: passed() else: failed("Use % operator") if __name__ == '__main__': run_common_tests("Use / and % operators") test_division() test_remainder()
else: failed("Wrong result") def test_remainder(): file = import_task_file() if file.remainder == 1.0: passed() else: failed("Wrong remainder") def test_windows(): windows = get_answer_placeholders() if "/" not in windows[0]: failed("Use / operator") return if "%" not in windows[1]: failed("Use % operator") return if "number" in windows[0] and "number" in windows[1]: passed() else: failed("Use the value stored in the variable \"number\"") if __name__ == '__main__': run_common_tests("Use / and % operators") test_windows() test_division() test_remainder()
def test_window1(): window = get_task_windows()[0] if "John" in window and "==" in window and "if " in window: passed() else: failed("Use if keyword") def test_window2(): window = get_task_windows()[1] if "else" in window: passed() else: failed("Use else keyword") def test_columns(): windows = get_task_windows() if ":" in windows[0] and ":" in windows[1]: passed() else: failed("Don't forget about column at the end") if __name__ == '__main__': run_common_tests("Use if/else keywords") test_window1() test_window2() test_columns()
from test_helper import run_common_tests, passed, failed, import_task_file, get_answer_placeholders def test_value(): file = import_task_file() if file.number == 12.0: passed() else: failed("Benutze den += Operator") def test_window(): window = get_answer_placeholders()[0] if "+=" in window: passed() else: failed("Benutze den += Operator") if __name__ == '__main__': run_common_tests("Du solltest die Datei ändern") test_value() test_window()
from test_helper import run_common_tests, failed, passed, get_answer_placeholders def test_window(): window = get_answer_placeholders()[0] if " and " in window and " or " in window and " not " in window: passed() else: failed("Use 'and', 'or' and 'not' keywords") if __name__ == '__main__': run_common_tests("Use 'and', 'or' and 'not' keywords") test_window()
from test_helper import run_common_tests, passed, failed, get_task_windows def test_window(): window = get_task_windows()[0] if "len(" in window: passed() else: failed("Use len() function") if __name__ == '__main__': run_common_tests("Use len() function")
from test_helper import run_common_tests, passed from exception_helper import handle_exception import unittest import task class Test(unittest.TestCase): def test_binary_array_to_number(self): try: self.assertEqual(task.binary_array_to_number([0, 0, 0, 1]), 1) self.assertEqual(task.binary_array_to_number([0, 0, 1, 0]), 2) self.assertEqual(task.binary_array_to_number([1, 1, 1, 1]), 15) self.assertEqual(task.binary_array_to_number([0, 1, 1, 0]), 6) self.assertEqual(task.binary_array_to_number([1, 1, 0, 0, 1, 0, 1, 1, 0] ), 406) self.assertEqual(task.binary_array_to_number([1, 1, 1, 0, 1, 1]), 59) self.assertEqual(task.binary_array_to_number([1, 0, 0, 0, 0, 0, 1, 1, 1, 1]), 527) self.assertEqual(task.binary_array_to_number([1, 1, 0, 0, 1, 0, 0, 1, 1]), 403) except Exception as e: handle_exception(e) passed() if __name__ == '__main__': run_common_tests() suite = unittest.TestLoader().loadTestsFromTestCase(Test) unittest.TextTestRunner(verbosity=2).run(suite)
failed("Falsches Ergebnis") def test_remainder(): file = import_task_file() if file.remainder == 1.0: passed() else: failed("Falscher Restwert") def test_windows(): windows = get_answer_placeholders() if not "/" in windows[0]: failed("Benutze den / Operator") return if not "%" in windows[1]: failed("Benutze den % Operator") return if "number" in windows[0] and "number" in windows[1]: passed() else: failed("Benutze den gespeicherten Wert in der Variable \"number\"") if __name__ == '__main__': run_common_tests("Benutze die / und % Operatoren") test_windows() test_division() test_remainder()