<commit_before>from unittest import TestCase

from chess_py import Board, Location, converter


class TestBishop(TestCase):
    def setUp(self):
        self.board = Board.init_default()

    def test_no_possible_moves(self):
        self.assertEqual(len(self.board.piece_at_square(Location.init_alg("c1"))
                             .possible_moves(self.board)), 0)

    def test_left_diagonal(self):
        self.board.update(converter.long_alg("b2b3", self.board))
        moves = self.board.piece_at_square(Location.init_alg("c1")).possible_moves(self.board)

        self.assertEqual(len(moves), 2)
        self.assertEqual(moves[0], converter.long_alg("c1b2", self.board))
        self.assertEqual(moves[1], converter.long_alg("c1a3", self.board))

    def test_capture(self):
        self.board.move_piece(Location.init_alg("g1"), Location.init_alg("g7"))
        moves = self.board.piece_at_square(Location.init_alg("f8")).possible_moves(self.board)

        self.assertEqual(len(moves), 1)
        self.assertEqual(moves[0], converter.long_alg("f8g7", self.board))

    def test_possible_moves(self):
        self.board.move_piece(Location.init_alg("c1"), Location.init_alg("d4"))
        test_moves = self.board.piece_at_square(Location.init_alg("d4")).possible_moves(self.board)
        real_moves = ["d4e5", "d4f6", "d4g7", "d4c5", "d4b6", "d4a7", "d4e3", "d4c3"]

        for i, move in enumerate(real_moves):
            self.assertEqual(move, str(test_moves[i]))

<commit_msg>Update Bishop tests to reflect switch to generators<commit_after>from unittest import TestCase

from chess_py import Board, Location, converter


class TestBishop(TestCase):
    def setUp(self):
        self.board = Board.init_default()

    def test_no_possible_moves(self):
        self.assertEqual(len(list(self.board.piece_at_square(Location.init_alg("c1"))
                             .possible_moves(self.board))), 0)

    def test_left_diagonal(self):
        self.board.update(converter.long_alg("b2b3", self.board))
        moves = list(self.board.piece_at_square(Location.init_alg("c1")).possible_moves(self.board))

        self.assertEqual(len(moves), 2)
        self.assertEqual(moves[0], converter.long_alg("c1b2", self.board))
        self.assertEqual(moves[1], converter.long_alg("c1a3", self.board))

    def test_capture(self):
        self.board.move_piece(Location.init_alg("g1"), Location.init_alg("g7"))
        moves = list(self.board.piece_at_square(Location.init_alg("f8")).possible_moves(self.board))

        self.assertEqual(len(moves), 1)
        self.assertEqual(moves[0], converter.long_alg("f8g7", self.board))

    def test_possible_moves(self):
        self.board.move_piece(Location.init_alg("c1"), Location.init_alg("d4"))
        test_moves = self.board.piece_at_square(Location.init_alg("d4")).possible_moves(self.board)
        real_moves = ["d4e5", "d4f6", "d4g7", "d4c5", "d4b6", "d4a7", "d4e3", "d4c3"]

        for i, move in enumerate(test_moves):
            self.assertEqual(str(move), real_moves[i])


{'fraction_non_alphanumeric': 0.14595660749506903, 'fraction_numerical': 0.024983563445101907, 'mean_word_length': 3.814873417721519, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '647539', 'n_tokens_mistral': 1086, 'n_tokens_neox': 1051, 'n_words': 143}