コード例 #1
0
 def test_add_line_moves_friendly(self, board):
     """Test add line moves with friendly pieces in the way
     returns the correct moves"""
     direction = (1, 0)
     board.is_open.side_effect = [True, True, False, False]
     board.is_enemy.return_value = False
     piece = Piece(board, WHITE, Position(1, 1))
     moves = piece.add_line_moves(direction)
     self.assertEqual(len(moves), 2)
     position = piece.position.copy()
     for i in range(2):
         position = position + direction
         self.assertIn(position, moves)
コード例 #2
0
 def test_add_line_moves_open_squares(self, board):
     """Test add line moves with only open squers returns
     the correct moves"""
     direction = (1, 0)
     board.is_open.return_value = True
     board.is_enemy.return_value = False
     piece = Piece(board, WHITE, Position(1, 1))
     moves = piece.add_line_moves(direction)
     self.assertEqual(len(moves), 6)
     position = piece.position.copy()
     for i in range(5):
         position = position + direction
         self.assertIn(position, moves)