Esempio n. 1
0
    def check(self, reply, attach):

        # Incorrect URL
        if attach is None:
            if '<p>' in reply:
                return CheckResult.wrong(
                    'You haven\'t checked was URL correct')
            else:
                return CheckResult.correct()

        # Correct URL
        if isinstance(attach, str):
            right_word = attach

            path_for_tabs = os.path.join(os.curdir, 'tb_tabs')

            if not os.path.isdir(path_for_tabs):
                return CheckResult.wrong("There are no directory for tabs")

            if not self._check_files(path_for_tabs, right_word):
                return CheckResult.wrong('There are no correct saved tabs')

            shutil.rmtree(path_for_tabs)

            if not Fore.BLUE in reply:
                return CheckResult.wrong('There are no blue refs in output')

            if '</p>' not in reply and '</div>' not in reply:
                if right_word in reply:
                    return CheckResult.correct()

            return CheckResult.wrong('You haven\'t parsed result of request')
Esempio n. 2
0
    def check(self, reply, attach):
        numbers = re.findall(r'[-+]?(\d*\.\d+|\d+)', reply)
        if len(numbers) == 0:
            return CheckResult.wrong(
                'No numbers in the answer',
            )

        if isinstance(attach, tuple):
            for i in numbers:
                if abs(attach[0] - float(i)) < 2:
                    return CheckResult.correct()
            output = 'Numbers in your answer: ' + ' '.join(numbers)
            output += 'But correct principal is {0}'.format(attach)
            return CheckResult.wrong(output)

        if isinstance(attach, list):
            # to exclude answers like 'it takes 2.01 years'
            # but 'it takes 2.0 years' let it be OK.
            epsilon = 0.00001
            numbers = [
                int(float(x)) for x in numbers
                if abs(int(float(x)) - float(x)) < epsilon
            ]
            if attach[1] == 0:
                if 'year' in reply and attach[0] in numbers:
                    return CheckResult.correct()

                output = 'Correct result: {0} years, but you output "{1}"'
                return CheckResult.wrong(
                    output.format(attach[0], reply),
                )
            else:
                if attach[0] in numbers and 'year' in reply:
                    if attach[1] in numbers and 'month' in reply:
                        return CheckResult.correct()

                output = (
                    'Correct result: {0} years {1} months, '
                    'but you output "{2}"'
                )
                return CheckResult.wrong(
                    output.format(attach[0], attach[1], reply),
                )

        if str(attach) not in reply:
            output = (
                'Correct annuity payment is {0} but you output numbers: {1}'
            )
            figures = ' '.join(numbers)
            return CheckResult.wrong(
                output.format(attach, figures),
            )

        return CheckResult.correct()
Esempio n. 3
0
 def _check_solution(self, test: TestCase, output: str):
     if isinstance(TestRun.curr_test_run.get_error_in_test(), TestPassed):
         return CheckResult.correct()
     try:
         if test.check_function is not None:
             return test.check_function(output, test.attach)
         else:
             return self.check(output, test.attach)
     except WrongAnswer as ex:
         return CheckResult.wrong(ex.feedback)
     except TestPassed:
         return CheckResult.correct()
Esempio n. 4
0
    def check(self, reply: str, attach: Any) -> CheckResult:

        survived = 'You survived!'
        hanged = 'You are hanged!'

        is_survived = survived in reply
        is_hanged = hanged in reply

        if is_survived and is_hanged:
            return CheckResult.wrong(
                f'Looks like your output contains both \"{survived}\"'
                f' and \"{hanged}\". You should output only one of them.'
            )

        if not is_survived and not is_hanged:
            return CheckResult.wrong(
                f'Looks like your output doesn\'t contain neither \"{survived}\"'
                f' nor \"{hanged}\". You should output one of them.'
            )

        if attach in out_of_description:
            if is_survived:
                return CheckResult.wrong(
                    f'Input contains a word out of the '
                    f'list form the description but the '
                    f'program output \"{survived}\"'
                )
            else:
                return CheckResult.correct()

        elif attach in description_list:

            if is_survived:
                hidden_attach = attach[:3] + '-'*len(attach[3:])
                if hidden_attach not in reply:
                    return CheckResult.wrong(
                        f'Program guessed the word \"{attach}\" '
                        f'and should output clue \"{hidden_attach}\" '
                        f'but this line is not in the output'
                    )

            catch[attach] += is_survived
            return CheckResult.correct()

        else:
            if any(v == 0 for v in catch.values()):
                return CheckResult.wrong(
                    "Looks like your program is not using "
                    "all of the words to guess from the list in description"
                )
            else:
                return CheckResult.correct()
Esempio n. 5
0
    def check(self, reply, attach):

        # Incorrect URL
        if attach is None:
            if 'error' in reply.lower():
                return CheckResult.correct()
            else:
                return CheckResult.wrong(
                    'There was no "error" word, but should be.')

        # Correct URL
        if isinstance(attach, tuple):

            if len(attach) == 4:
                _, *attach = attach
                if 'error' not in reply.lower():
                    return CheckResult.wrong(
                        'There was no "error" word, but should be.')

            right_word, wrong_word, correct_file_name = attach

            path_for_tabs = 'tb_tabs'

            if not os.path.isdir(path_for_tabs):
                return CheckResult.wrong(
                    "Can't find a directory \"" + path_for_tabs + "\" "
                    "in which you should save your web pages.")

            if not self._check_files(path_for_tabs, right_word):
                return CheckResult.wrong(
                    "Seems like you did\'n save the web page "
                    "\"" + right_word + "\" into the "
                    "directory \"" + path_for_tabs + "\". "
                    "This file with page should be named \"" +
                    correct_file_name + "\"")

            try:
                shutil.rmtree(path_for_tabs)
            except PermissionError:
                return CheckResult.wrong(
                    "Impossible to remove the directory for tabs. Perhaps you haven't closed some file?"
                )

            if wrong_word in reply:
                return CheckResult.wrong(
                    'It seems like you printed wrong variable')

            if right_word in reply:
                return CheckResult.correct()

            return CheckResult.wrong(
                'You printed neither bloomberg_com nor nytimes_com')
Esempio n. 6
0
    def check(self, reply, attach=None):
        scraper = NatureScraper()
        txt_files = glob.glob("*.txt")
        article_links = scraper.get_article_links_of_type(
            "https://www.nature.com/nature/articles")
        if len(txt_files) != len(article_links):
            return CheckResult.wrong(
                "A wrong number of files with articles was found. \n"
                "{0} files were found, {1} files were expected.".format(
                    len(txt_files), len(article_links)))

        if not article_links:
            return CheckResult.correct()
        title, content = None, None
        while not title or not content:
            article_n = random.randint(0, len(article_links) - 1)
            title, content = scraper.get_article_title_and_content(
                article_links[article_n])
            if not title or not content:
                article_links.pop(article_n)
                if not article_links:
                    return CheckResult.correct()
        title = f"{title.translate(str.maketrans('', '', string.punctuation)).replace(' ', '_')}.txt"
        if not os.path.exists(title):
            return CheckResult.wrong(
                "A file with the name \"{0}\" was not found.\n"
                "Make sure you remove punctuation and \nreplace the whitespaces with underscores in the titles."
                .format(title))
        with open(title, "rb") as f:
            try:
                file_content = f.read().decode('utf-8').strip()
            except UnicodeDecodeError:
                return CheckResult.wrong(
                    "An error occurred when tests tried to read the file \"{0}\"\n"
                    "Please, make sure you save your file in binary format \n"
                    "and encode the saved data using utf-8 encoding.".format(
                        title))
        file_content = re.sub('[\r\n]', '', file_content)
        content = re.sub('[\r\n]', '', content)
        if content in file_content:
            return CheckResult.correct()
        else:
            return CheckResult.wrong(
                "Some of the files do not contain the expected article's body. \n"
                "The tests expected the following article:\n"
                f"\"{content}\"\n"
                f"However, the following text was found in the file {title}:\n"
                f"\"{file_content}\"")
    def check2(self, reply, attach):
        if 'support korean' in reply.lower():
            return CheckResult.correct()

        return CheckResult.wrong(
            'Your program does not output an error message about an unsupported language.'
        )
 def check1(self, reply, attach):
     reply = reply.lower()
     if 'unable' not in reply:
         return CheckResult.wrong(
             'Your program does not output an error message for an nonexistent word.'
         )
     return CheckResult.correct()
Esempio n. 9
0
    def check_sys_import(reply, attach):
        reply = reply.lower()
        if "cards have been loaded" not in reply:
            return CheckResult.wrong(
                "The user has provided the --import_from command-line argument. \n"
                "So, in the beginning of the game, \n"
                "your program should load the cards from the file specified in the command-line argument\n."
                "After that, a message about the number of cards that have been loaded should be printed by your program.\n"
                "However, this message was not found.")
        if "3 cards have been loaded" not in reply:
            return CheckResult.wrong(
                "Seems like your program incorrectly printed the number of cards "
                "imported from the file in the beginning of the game.")
        if reply.count("has been removed") != 2:
            return CheckResult.wrong(
                "Your program was asked to remove several existing cards, \n"
                "however, it seems that it did not do it, \n"
                "or did not output the message \"The card has been removed.\"")
        if right_keyword not in reply:
            return CheckResult.wrong(
                "The user gave a correct answer, "
                "but your program did not output the word \"{}\".".format(
                    right_keyword))
        if wrong_keyword not in reply:
            return CheckResult.wrong(
                "The user gave a wrong answer, "
                "but your program did not output the word \"{}\".".format(
                    wrong_keyword))

        return CheckResult.correct()
Esempio n. 10
0
    def check_duplicate(self):
        main = TestedProgram()
        output = main.start(root_dir_path).lower()
        output = main.execute("").lower()
        output = main.execute("1").lower()
        output = main.execute("yes").lower().split('\n')

        hash_arr = [
            '95708df6eb2d9e30c128cf14dcf91f5b',
            'c2a5ad1655d8d46d7d699594c1ee0dec',
            'a5ceea9b58986bc87fb85f999d76d9db',
            'd63a4f1856c5fa167b1aaa6529d9846f'
        ]

        n = 0
        for val in output:
            if 'hash' in val:
                n += 1
                string, hash_user = val.split()
                if hash_user not in hash_arr:
                    return CheckResult.wrong(
                        f"There is no duplicate with hash {hash_user}")
        if n < 4:
            return CheckResult.wrong(f"You have missed some files")
        return CheckResult.correct()
Esempio n. 11
0
    def check_size_duplicate(self):
        main = TestedProgram()
        output = main.start(root_dir_path).lower()
        output = main.execute("").lower()
        output = main.execute("2").lower()
        output = main.execute("yes").lower().split('\n')
        output = [val for val in output if val]
        size = None

        for val in output:
            if 'byte' in val:
                for i in val.split():
                    if i.isdigit():
                        size = int(i)
            elif 'delete' not in val and os.sep in val:
                temp = val.split()
                if len(temp) < 2:
                    return CheckResult.wrong(
                        "Your output is incorrect! "
                        "Make sure that the file paths are printed as in the examples"
                    )
                path = ' '.join(temp[1:])
                try:
                    file_size = os.path.getsize(path)
                except FileNotFoundError:
                    return CheckResult.wrong(
                        f"Your output contains invalid file path:\n"
                        f"{val}")
                if size != file_size:
                    return CheckResult.wrong(f"{val} has wrong size group")
        return CheckResult.correct()
Esempio n. 12
0
    def check_duplicate_hash(self):
        main = TestedProgram()
        output = main.start(root_dir_path).lower()
        output = main.execute("").lower()
        output = main.execute("1").lower()
        output = main.execute("yes").lower().split('\n')

        hash_user = None
        for val in output:
            if 'hash' in val:
                temp = val.split()
                if len(temp) != 2:
                    return CheckResult.wrong(
                        f"The following line has wrong output format:\n{val}\n"
                        f"Make sure you output it like in examples!")
                hash_user = temp[1]
            elif '.' in val:
                temp = val.split()
                if len(temp) < 2:
                    return CheckResult.wrong(
                        "Your output is incorrect! "
                        "Make sure that the file paths are printed as in the examples"
                    )
                path = ' '.join(temp[1:])
                with open(path, 'rb') as f:
                    hasher = hashlib.md5()
                    hasher.update(f.read())
                    hash_val = hasher.hexdigest()
                if hash_user != hash_val:
                    return CheckResult.wrong(
                        f"Wrong file hash. File: {val}, hash: {hash_user} ")

        return CheckResult.correct()
Esempio n. 13
0
 def check_soln_exist(self, reply: str, attach: Any) -> CheckResult:
     reply = reply.lower()
     if "here" not in reply or "solution" not in reply:
         return CheckResult.wrong(
             "Solution should exist. You need to show the solution and a message"
         )
     return CheckResult.correct()
 def check_quit(self, output):
     if "you sure you want to quit the game? y/n " in output.lower():
         return "y"
     elif "goodbye!" in output.lower():
         return CheckResult.correct()
     else:
         return CheckResult.wrong("You didn't ask to quit the game.")
    def check_level1(self, output):
        choices = ["1", "2", "3"]
        random_choice = choice(choices)
        if "level 2" in output.lower():
            return CheckResult.correct()
        elif "game over" in output.lower():
            return "1"
        elif "starting a new game" in output.lower():
            return self.username
        elif "1- name" in output.lower():
            return self.name
        elif "2- species" in output.lower():
            return self.species
        elif "3- gender" in output.lower():
            return self.gender
        elif "1- favourite snack" in output.lower():
            return self.snack
        elif "2- a weapon for the journey" in output.lower():
            return self.weapon
        elif "3- a traversal tool" in output.lower():
            return self.tool
        elif "choose your difficulty" in output.lower():
            return self.difficulty

        if "you died" in output.lower() and "level 1" not in output.lower():
            return CheckResult.wrong("Your program didn't start from the beginning of the level.")

        if "what will you do? type the number of the option or type '/h' to show help." not in output.lower():
            choices.pop(choices.index(self.picked_choice))
            self.picked_choice = choice(choices)
            return self.picked_choice

        else:
            self.picked_choice = random_choice
            return self.picked_choice
 def check_help(self, output):
     message = "type the number of the option you want to choose.\n" + "commands you can use:\n/i => shows inventory.\n" \
               + "/q => exits the game.\n" + "/c => shows the character traits.\n" + "/h => shows help."
     if message not in output.lower():
         return CheckResult.wrong("Your program didn't output the correct help message.")
     else:
         return CheckResult.correct()
 def check_char(self, output):
     char = [self.name, self.species, self.gender, self.lives]
     in_char = all([ch in output.lower() for ch in char])
     if "character" not in output.lower() or not in_char or "lives remaining" not in output.lower():
         return CheckResult.wrong("Your program didn't output correct character traits.")
     else:
         return CheckResult.correct()
Esempio n. 18
0
 def check(self, reply: str, attach) -> CheckResult:
     try:
         with open(attach.out_file, 'r') as filik:
             try:
                 cor_answers = attach.answers
                 replyk = [
                     i.strip().replace("[",
                                       "").replace("]",
                                                   "").replace("'", "")
                     for i in filik.readlines()
                 ]
                 hum_answers = np.array(
                     list(map(lambda x: np.float64(x), replyk)))
                 n = hum_answers.size
                 if n != len(attach.answers):
                     return CheckResult.wrong(attach.feedback)
                 for i in range(n):
                     if abs(hum_answers[i] - cor_answers[i]) > 0.001:
                         return CheckResult.wrong(attach.feedback)
             except ValueError:
                 with open(attach.out_file, 'r') as filik:
                     hum_answer = filik.readline()
                     if hum_answer.strip() != attach.answers:
                         return CheckResult.wrong(attach.feedback)
     except IOError:
         return CheckResult.wrong("File doesn't exist or cannot be opened. "
                                  "Did you close the file in your program?")
     return CheckResult.correct()
Esempio n. 19
0
    def check_db_file(self, reply, attach):
        if not os.path.exists('todo.db'):
            return CheckResult.wrong(
                'You didn\'t create the database file. It should be name todo.db'
            )
        shutil.copy2('todo.db', 'temp.db')

        tables_in_db = self.execute('SELECT  name FROM sqlite_master '
                                    'WHERE type =\'table\' AND name '
                                    'NOT LIKE \'sqlite_%\';')
        tables_in_db = [table[0] for table in tables_in_db]
        if 'task' not in tables_in_db:
            return CheckResult.wrong(
                'Your database doesn\'t have \'task\' table.')

        columns_in_table = self.execute('PRAGMA table_info(task)')
        columns_in_table = [[*column[1:3]] for column in columns_in_table]
        correct_columns = ['id', 'INTEGER'], ['task',
                                              'VARCHAR'], ['deadline', 'DATE']
        for column in correct_columns:
            if column not in columns_in_table:
                return CheckResult.wrong(
                    'Your table should contain \'{}\' column with \'{}\' type'.
                    format(column[0], column[1]))
        return CheckResult.correct()
Esempio n. 20
0
    def check_sys_import_export(reply, attach):
        reply = reply.lower()
        if "cards have been loaded" not in reply:
            return CheckResult.wrong("The user has provided the --import_from command-line argument. \n"
                                     "So, in the beginning of the game, \n"
                                     "your program should load the cards from the file specified in the command-line argument\n."
                                     "After that, a message about the number of cards that have been loaded should be printed by your program.\n"
                                     "However, this message was not found.")
        if "3 cards have been loaded" not in reply:
            return CheckResult.wrong("Seems like your program incorrectly printed the number of cards "
                                     "imported from the file in the beginning of the game.")

        if right_keyword not in reply and (wrong_keyword not in reply and "but your definition is correct for"):
            return CheckResult.wrong("Your program did not respond correctly to the user's answer on the question.\n"
                                     "Make sure you've imported cards from the file specified in the --import_from command-line argument.")
        if "cards have been saved" not in reply.lower():
            return CheckResult.wrong("The user has provided the --export_to command-line argument. \n"
                                     "So, after the user inputs the command \"exit\", \n"
                                     "your program should save the cards to the file specified in the command-line argument\n."
                                     "After that, a message about the number of cards that have been saved should be printed by your program.\n"
                                     "However, this message was not found.")
        if "3 cards have been saved" not in reply.lower():
            return CheckResult.wrong("Seems like your program incorrectly printed the number of cards "
                                     "exported to file after \"exit\" command.")
        if not os.path.exists(attach):
            return CheckResult.wrong("The user has provided the --export_to command-line argument. \n"
                                     "However, the file where the cards should have been exported after \"exit\" was not found. "
                                     "Make sure you named the file with exported cards "
                                     "as was required in --export_to command-line argument.")
        try:
            os.remove(attach)
        except PermissionError:
            return CheckResult.wrong("Impossible to remove the file with the exported cards. "
                                     "Perhaps you haven't closed this file?")
        return CheckResult.correct()
Esempio n. 21
0
 def check(self, reply: str, attach) -> CheckResult:
     repl_parsed = [
         i.strip() for i in reply.split('Checking the cache...') if i
     ]
     if len(repl_parsed) != len(attach):
         return CheckResult.wrong("Make sure your output is well-formated")
     for i, curr in enumerate(repl_parsed):
         curr_split = curr.split('\n')
         if len(curr_split) != 2:
             return CheckResult.wrong(
                 "Make sure you output exactly three lines after each set of inputs.\n"
             )
         curr0, curr1 = curr_split
         if attach[i][1] not in curr0:
             return CheckResult.wrong("Check the data in your cache")
         try:
             amount = float(curr1.split()[-2])
         except ValueError:
             return CheckResult.wrong(
                 "Your output is incorrectly formatted.")
         except IndexError:
             return CheckResult.wrong(
                 "The output of your program seems to be incorrectly formatted.\n"
                 "Make sure you output the result in the format:\n"
                 "\"You received {value} {currency}.\"")
         if abs(amount - attach[i][2]) > 0.2:
             return CheckResult.wrong(
                 f"The amount of {attach[i][0]} is wrong")
     return CheckResult.correct()
Esempio n. 22
0
 def check(self, reply: str, attach) -> CheckResult:
     ccoins_att, currs_att = attach
     reply_parsed = reply.strip().split('\n')
     if len(reply_parsed) != 5:
         return CheckResult.wrong("Your output differs from the example")
     for repl in reply_parsed:
         repl = repl.lower()
         repl_parsed = repl.strip().split()
         if len(repl_parsed) != 11:
             return CheckResult.wrong(
                 "Your output differs from the example")
         try:
             cur = float(repl_parsed[3])
             ccoins = float(repl_parsed[-2])
             key = repl_parsed[4]
         except (ValueError, KeyError):
             return CheckResult.wrong(
                 "Format your output according to the example")
         if ccoins != ccoins_att:
             return CheckResult.wrong("The amount of conicoins is wrong")
         try:
             amount_curr = currs_att[key]
         except KeyError:
             return CheckResult.wrong(
                 "The currency name in the output of your program seems to be wrong:\n"
                 "\"{0}\"".format(key.upper()))
         if abs(amount_curr - cur) > 0.2:
             return CheckResult.wrong(
                 f"The amount of {key.upper()} is wrong")
         if not ('i will get' in repl and 'from the sale of' in repl
                 and 'conicoins' in repl):
             return CheckResult.wrong(
                 "Format your output according to the example")
     return CheckResult.correct()
Esempio n. 23
0
def checkMove(board):
    movelist = []
    lastx = moves[-1][0]
    lasty = moves[-1][1]
    for i in range(DIRECTIONS):
        new_x = lastx + move_x[i]  # user coordinates 1 - n
        new_y = lasty + move_y[i]  # user coordinates 1 - n
        if new_x in range(1, ncols + 1) and new_y in range(
                1, nrows + 1) and ("_" in board[new_y - 1][new_x - 1]
                                   or board[new_y - 1][new_x - 1].isnumeric()):
            movelist.append([new_x, new_y])

    for i in range(ncols):  # i = x = cols
        for j in range(nrows):  # j = y = rows
            if [i + 1, j + 1] in movelist:
                possible = warnsdorff(i + 1, j + 1, board)
                if board[j][i] != str(possible):
                    return False, CheckResult.wrong(
                        "Incorrect value or marker missing from possible move")
            elif i + 1 == lastx and j + 1 == lasty:
                if board[j][i] not in ["x", "X"]:
                    return False, CheckResult.wrong(
                        "Incorrect starting position or marker")
            elif [i + 1, j + 1] in moves:
                if board[j][i] != "*":
                    return False, CheckResult.wrong(
                        "Incorrect marker or marker missing from previous move"
                    )
            else:
                if "_" not in board[j][i]:
                    return False, CheckResult.wrong(
                        "Markers placed in wrong location")
    return True, CheckResult.correct()
Esempio n. 24
0
 def check_incorrect_url(self, reply, attach=None):
     if "Invalid movie page!" in reply:
         return CheckResult.correct()
     else:
         return CheckResult.wrong(
             """If the link does not contain movie info or not an IMDB resource, 
         please respond with 'Invalid movie page!' message!""")
Esempio n. 25
0
 def check_request_mode(self, output):
     output = output.lower()
     if "puzzle" not in output or "try" not in output:
         return CheckResult.wrong(
             "Your program should ask if the player wants to try the puzzle"
         )
     return CheckResult.correct()
Esempio n. 26
0
    def check_the_win(self, reply: list, attach: Any) -> CheckResult:
        design = '=' * 70
        if not reply:
            raise WrongAnswerException(
                "The reply is empty. Please, output the required data.")
        reply_parsed = reply.split(design)
        the_last = [
            i.strip() for i in reply_parsed[-1].strip().split('\n') if i
        ]
        try:
            comp_pieces = int([i.strip() for i in the_last[1].split(':')
                               if i][-1])
        except Exception:
            raise WrongAnswerException(
                "Make sure you output pieces in the required format.")

        last_output = reply_parsed[-1].replace(' ', '')
        # check for the win
        if '1:[' not in last_output:
            if ':[' in last_output or comp_pieces == 0:
                return CheckResult.wrong("The result is wrong")
            if "the game is over. you won" not in the_last[-1].lower():
                return CheckResult.wrong("The status is not right")
        # check for the computer win
        elif int(the_last[1][-1]) == 0:
            if ':[' not in last_output or comp_pieces > 0:
                return CheckResult.wrong("The result is wrong")
            if "the game is over. the computer won" not in the_last[-1].lower(
            ):
                return CheckResult.wrong("The status is not right")
        else:
            if "the game is over. it's a draw" not in the_last[-1].lower():
                return CheckResult.wrong("The status is not right")
        return CheckResult.correct()
 def check_menu(reply, attach):
     if menu in reply.lower():
         return CheckResult.correct()
     else:
         return CheckResult.wrong(
             'Your program doesn\'t show the menu from example.\n'
             ' Make sure you didn\'t print any extra spaces')
Esempio n. 28
0
 def generate(self) -> List[TestCase]:
     return [
         TestCase(stdin=['12'], attach='1\n12\n'),
         TestCase(stdin=[lambda x: CheckResult.correct()]),
         TestCase(stdin=[lambda x: CheckResult(x == '1\n', x + '56')]),
         TestCase(stdin=[lambda x: 78])
     ]
Esempio n. 29
0
 def check_the_lost(self, reply: list, attach: Any) -> CheckResult:
     design = '=' * 70
     reply_parsed = reply.split(design)
     the_last = [i for i in reply_parsed[-1].strip().split('\n') if i]
     if "the game is over. the computer won" not in the_last[-1].lower():
         return CheckResult.wrong("The status is not right")
     return CheckResult.correct()
Esempio n. 30
0
 def check_format_choice(self):
     main = TestedProgram()
     output = main.start(root_dir_path).lower()
     if 'format' in output:
         return CheckResult.correct()
     return CheckResult.wrong(
         "You should read the user's choice of file format")