diff --git a/tests/test_board.py b/tests/test_board.py index 83839a3..9f11c4c 100644 --- a/tests/test_board.py +++ b/tests/test_board.py @@ -2,6 +2,7 @@ import pytest from katrain.core.game import Game, IllegalMoveException, Move from katrain.core.base_katrain import KaTrainBase, OUTPUT_INFO +from katrain.core.game_node import GameNode class MockKaTrain(KaTrainBase): @@ -17,12 +18,17 @@ class MockEngine: pass +@pytest.fixture +def new_game(): + return GameNode(properties={"SZ": 19}) + + class TestBoard: def nonempty_chains(self, b): return [c for c in b.chains if c] - def test_merge(self): - b = Game(MockKaTrain(), MockEngine()) + def test_merge(self, new_game): + b = Game(MockKaTrain(), MockEngine(), move_tree=new_game) b.play(Move.from_gtp("B9", player="B")) b.play(Move.from_gtp("A3", player="B")) b.play(Move.from_gtp("A9", player="B")) @@ -30,8 +36,8 @@ class TestBoard: assert 3 == len(b.stones) assert 0 == len(b.prisoners) - def test_collide(self): - b = Game(MockKaTrain(), MockEngine()) + def test_collide(self, new_game): + b = Game(MockKaTrain(), MockEngine(), move_tree=new_game) b.play(Move.from_gtp("B9", player="B")) with pytest.raises(IllegalMoveException): b.play(Move.from_gtp("B9", player="W")) @@ -39,8 +45,8 @@ class TestBoard: assert 1 == len(b.stones) assert 0 == len(b.prisoners) - def test_capture(self): - b = Game(MockKaTrain(), MockEngine()) + def test_capture(self, new_game): + b = Game(MockKaTrain(), MockEngine(), move_tree=new_game) b.play(Move.from_gtp("A2", player="B")) b.play(Move.from_gtp("B1", player="W")) b.play(Move.from_gtp("A1", player="W")) @@ -60,8 +66,8 @@ class TestBoard: assert 4 == len(b.stones) assert 2 == len(b.prisoners) - def test_snapback(self): - b = Game(MockKaTrain(), MockEngine()) + def test_snapback(self, new_game): + b = Game(MockKaTrain(), MockEngine(), move_tree=new_game) for move in ["C1", "D1", "E1", "C2", "D3", "E4", "F2", "F3", "F4"]: b.play(Move.from_gtp(move, player="B")) for move in ["D2", "E2", "C3", "D4", "C4"]: @@ -78,8 +84,8 @@ class TestBoard: assert 12 == len(b.stones) assert 4 == len(b.prisoners) - def test_ko(self): - b = Game(MockKaTrain(), MockEngine()) + def test_ko(self, new_game): + b = Game(MockKaTrain(), MockEngine(), move_tree=new_game) for move in ["A2", "B1"]: b.play(Move.from_gtp(move, player="B"))