Пример #1
0
def test_board_setup():
    # as long as length of piece list is equal to row x column, the board yields no error and loads from top left down to bottom right
    b = Board([Fire, Water, Wood, Dark, Light, Heart], 2, 3)
    assert isinstance(b, Board), "Board valid 2x3, but was not instantiated!"
    assert isinstance(b.cell(0, 0), Fire), "Unexpected piece @ 0,0 on 2x3 Board!"
    assert isinstance(b.cell(0, 1), Water), "Unexpected piece @ 0,1 on 2x3 Board!"
    assert isinstance(b.cell(0, 2), Wood), "Unexpected piece @ 0,2 on 2x3 Board!"
    assert isinstance(b.cell(1, 0), Dark), "Unexpected piece @ 1,0 on 2x3 Board!"
    assert isinstance(b.cell(1, 1), Light), "Unexpected piece @ 1,1 on 2x3 Board!"
    assert isinstance(b.cell(1, 2), Heart), "Unexpected piece @ 1,2 on 2x3 Board!"
    assert b.rows == 2, "2x3 board has incorrect rows property!"
    assert b.columns == 3, "2x3 board has incorrect columns property!"
    assert len(b.board) == 2 and len(b.board[0]) == 3, "2x3 board has incorrect board dimensions!"

    b = Board([Fire, Water, Wood, Dark, Light, Heart], 3, 2)
    assert isinstance(b, Board), "Board valid 3x2, but was not instantiated!"
    assert isinstance(b.cell(0, 0), Fire), "Unexpected piece @ 0,0 on 3x2 Board!"
    assert isinstance(b.cell(0, 1), Water), "Unexpected piece @ 0,1 on 3x2 Board!"
    assert isinstance(b.cell(1, 0), Wood), "Unexpected piece @ 1,0 on 3x2 Board!"
    assert isinstance(b.cell(1, 1), Dark), "Unexpected piece @ 1,1 on 3x2 Board!"
    assert isinstance(b.cell(2, 0), Light), "Unexpected piece @ 2,0 on 3x2 Board!"
    assert isinstance(b.cell(2, 1), Heart), "Unexpected piece @ 2,1 on 3x2 Board!"
    assert b.rows == 3, "3x2 board has incorrect rows property!"
    assert b.columns == 2, "3x2 board has incorrect columns property!"
    assert len(b.board) == 3 and len(b.board[0]) == 2, "3x2 board has incorrect board dimensions!"
Пример #2
0
def test_board_setup():
    # as long as length of piece list is equal to row x column, the board yields no error and loads from top left down to bottom right
    b = Board([Fire, Water, Wood, Dark, Light, Heart], 2, 3)
    assert isinstance(b, Board), "Board valid 2x3, but was not instantiated!"
    assert isinstance(b.cell(0, 0),
                      Fire), "Unexpected piece @ 0,0 on 2x3 Board!"
    assert isinstance(b.cell(0, 1),
                      Water), "Unexpected piece @ 0,1 on 2x3 Board!"
    assert isinstance(b.cell(0, 2),
                      Wood), "Unexpected piece @ 0,2 on 2x3 Board!"
    assert isinstance(b.cell(1, 0),
                      Dark), "Unexpected piece @ 1,0 on 2x3 Board!"
    assert isinstance(b.cell(1, 1),
                      Light), "Unexpected piece @ 1,1 on 2x3 Board!"
    assert isinstance(b.cell(1, 2),
                      Heart), "Unexpected piece @ 1,2 on 2x3 Board!"
    assert b.rows == 2, "2x3 board has incorrect rows property!"
    assert b.columns == 3, "2x3 board has incorrect columns property!"
    assert len(b.board) == 2 and len(
        b.board[0]) == 3, "2x3 board has incorrect board dimensions!"

    b = Board([Fire, Water, Wood, Dark, Light, Heart], 3, 2)
    assert isinstance(b, Board), "Board valid 3x2, but was not instantiated!"
    assert isinstance(b.cell(0, 0),
                      Fire), "Unexpected piece @ 0,0 on 3x2 Board!"
    assert isinstance(b.cell(0, 1),
                      Water), "Unexpected piece @ 0,1 on 3x2 Board!"
    assert isinstance(b.cell(1, 0),
                      Wood), "Unexpected piece @ 1,0 on 3x2 Board!"
    assert isinstance(b.cell(1, 1),
                      Dark), "Unexpected piece @ 1,1 on 3x2 Board!"
    assert isinstance(b.cell(2, 0),
                      Light), "Unexpected piece @ 2,0 on 3x2 Board!"
    assert isinstance(b.cell(2, 1),
                      Heart), "Unexpected piece @ 2,1 on 3x2 Board!"
    assert b.rows == 3, "3x2 board has incorrect rows property!"
    assert b.columns == 2, "3x2 board has incorrect columns property!"
    assert len(b.board) == 3 and len(
        b.board[0]) == 2, "3x2 board has incorrect board dimensions!"