def test_blocked_pawn_2(): board = Board() King(board, (0, 0), 'white') pawn = Pawn(board, (1, 0), 'white') King(board, (2, 0), 'black') moves = [move for move in pawn.generate_moves()] assert len(moves) == 0
def test_pawn_promotion(): board = Board() King(board, (0, 0), 'white') pawn = Pawn(board, (6, 0), 'white') King(board, (7, 7), 'black') moves = [move for move in pawn.generate_moves()] assert len(moves) == 1 assert isinstance(moves[0].get_piece_by_position((7, 0)), Queen)
def test_pawn_attack_2(): board = Board() King(board, (0, 0), 'white') pawn = Pawn(board, (5, 5), 'black') Bishop(board, (4, 4), 'white') King(board, (7, 6), 'black') moves = [move for move in pawn.generate_moves()] assert len(moves) == 2
def test_pawn_attack_1(): board = Board() King(board, (0, 0), 'white') pawn = Pawn(board, (1, 0), 'white') Bishop(board, (2, 1), 'black') King(board, (7, 7), 'black') moves = [move for move in pawn.generate_moves()] assert len(moves) == 3
def test_en_passant(): board = Board() King(board, (0, 0), 'white') Pawn(board, (1, 0), 'white') Pawn(board, (3, 1), 'black') King(board, (7, 7), 'black') move = Move((1, 0), (3, 0), special_move='pawn_double') new_board = board.copy_and_execute_move(move) assert new_board.en_passant['black'][0] black_pawn = new_board.get_piece_by_position((3, 1)) moves = [move for move in black_pawn.generate_moves()] assert len(moves) == 2 move = Move((3, 1), (2, 0), special_move='en_passant') newest_board = new_board.copy_and_execute_move(move) assert len([piece for piece in newest_board.pieces]) == 3