コード例 #1
0
def test_repr():
    """Test__repr__"""
    d = Disk(100, 150, 50)
    d.draw_black = True
    assert repr(d) == "Black"
    d1 = Disk(100, 150, 50)
    d1.draw_black = False
    assert repr(d1) == "White"
コード例 #2
0
 def flip_tiles(self, x, y, is_black):
     """Flip tile colors in all eight directions.
     INT, INT -> BOOLEAN"""
     d = Disk(x, y, self.cell)
     position = (d.row, d.column)
     self._flip_tiles_one_dir(self._move_right(position), self._move_right,
                              is_black)
     self._flip_tiles_one_dir(self._move_left(position), self._move_left,
                              is_black)
     self._flip_tiles_one_dir(self._move_up(position), self._move_up,
                              is_black)
     self._flip_tiles_one_dir(self._move_down(position), self._move_down,
                              is_black)
     self._flip_tiles_one_dir(self._move_left_up(position),
                              self._move_left_up, is_black)
     self._flip_tiles_one_dir(self._move_left_down(position),
                              self._move_left_down, is_black)
     self._flip_tiles_one_dir(self._move_right_up(position),
                              self._move_right_up, is_black)
     self._flip_tiles_one_dir(self._move_right_down(position),
                              self._move_right_down, is_black)
     d.draw_black = is_black
     d.display()
     self.table[d.row][d.column] = d
     self.total_count += 1
     self.check_legal(self.gr.player_turn)
コード例 #3
0
def test_constructor():
    """Test constructor"""
    d = Disk(100, 150, 50)
    assert d.x == 100
    assert d.y == 150
    assert d.CELL == 50
    d.draw_black = False
    assert d.draw_black is False
    assert d.column == 2
    assert d.row == 3