Fix fen loading tests

This commit is contained in:
2025-08-22 14:47:19 -04:00
parent 5ddb359675
commit 2a7948eab4
4 changed files with 51 additions and 70 deletions

View File

@@ -1,37 +1,15 @@
import unittest
from binding.python_c_ffi import Board
from binding.python_c_ffi import ChessFFI
from test.chess_ffi import Board
from test.chess_ffi import KING_ATTACKS
from test.chess_ffi import KNIGHT_ATTACKS
from test.chess_ffi import PAWN_ATTACKS
from test.chess_ffi import gen_moves
from test.chess_ffi import init_attack_caches
from test.chess_ffi import load_fen
class ChessLibTestBase(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.chess_ffi = ChessFFI()
init_attack_caches()
cls.KNIGHT_ATTACKS = KNIGHT_ATTACKS
cls.KING_ATTACKS = KING_ATTACKS
cls.PAWN_ATTACKS = PAWN_ATTACKS
cls.chess_ffi.init_attack_cache()
def setUp(self):
# This should be an empty board for each test in the suite.
self.board = Board()
def load_fen(self, fen, board=None):
if board:
return self.chess_ffi.load_fen(board, fen)
return self.chess_ffi.load_fen(self.board, fen)
def gen(self, captures_only: bool = False, cap: int = 256):
return gen_moves(self.board, captures_only=captures_only, cap=cap)
self.board = Board()