Exemple #1
0
    def test_rerun_playthroughs(self):
        test_srcdir = os.environ.get("TEST_SRCDIR", "")
        path = os.path.join(test_srcdir, _DATA_DIR)

        basenames = list(os.listdir(path))
        self.assertGreaterEqual(len(basenames), 40)

        for basename in basenames:
            file_path = os.path.join(path, basename)
            logging.info(basename)

            # We check whether the game is optional, and if it is, whether we do
            # have the game.
            is_optional, game_name = _is_optional_game(basename)
            if is_optional:
                if game_name not in _AVAILABLE_GAMES:
                    logging.info("Skipping %s because %s is not built in.",
                                 basename, game_name)
                    continue

            expected, actual = generate_playthrough.replay(file_path)
            for line_num, (expected_line, actual_line) in enumerate(
                    zip(expected.split("\n"), actual.split("\n"))):
                self.assertEqual(expected_line,
                                 actual_line,
                                 msg="Wrong line {} in {}".format(
                                     line_num, basename))

            self.assertMultiLineEqual(
                expected,
                actual,
                msg="Issue with basename {}".format(basename))
Exemple #2
0
    def test_rerun_playthroughs(self):
        test_srcdir = os.environ.get("TEST_SRCDIR", "")
        path = os.path.join(test_srcdir, _DATA_DIR)

        file_paths = list(os.listdir(path))
        self.assertGreaterEqual(len(file_paths), 5)

        for filename in file_paths:
            file_path = os.path.join(path, filename)
            logging.info(filename)
            expected, actual = generate_playthrough.replay(file_path)
            for expected_line, actual_line in zip(expected.split("\n"),
                                                  actual.split("\n")):
                self.assertEqual(expected_line, actual_line)

            self.assertMultiLineEqual(
                expected,
                actual,
                msg="Issue with filename {}".format(filename))
    def run_test(self, path, basename):
        """Instantiated for each test case in main, below."""

        # We check whether the game is optional, and if it is, whether we do
        # have the game.
        is_optional, game_name = _is_optional_game(basename)
        if is_optional:
            if game_name not in _AVAILABLE_GAMES:
                logging.info("Skipping %s because %s is not built in.",
                             basename, game_name)
                return

        file_path = os.path.join(path, basename)
        expected, actual = generate_playthrough.replay(file_path)
        for line_num, (expected_line, actual_line) in enumerate(
                zip(expected.split("\n"), actual.split("\n"))):
            self.assertEqual(expected_line,
                             actual_line,
                             msg="Wrong line {} in {}".format(
                                 line_num, basename))
        self.assertMultiLineEqual(expected, actual)