Skip to content

Commit

Permalink
Bump version + add some more tests for Board.
Browse files Browse the repository at this point in the history
  • Loading branch information
arnauddupuis committed Sep 1, 2020
1 parent 98c773b commit dc1fcbc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pygamelib/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"""

# Main version
PYGAMELIB_VERSION = "1.2.1"
PYGAMELIB_VERSION = "1.2.2"

# Directions
NO_DIR = 10000000
Expand Down
12 changes: 10 additions & 2 deletions pygamelib/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,11 @@ def display_around(self, item, row_radius, column_radius):
" column_radius needs to be int."
)
clear_eol = "\x1b[K"
if isinstance(self.parent, Game) and isinstance(self.parent.terminal, Terminal):
# This statement doesn't registered as tested but it is. In tests/test_board.py
# in test_partial_display.
if isinstance(self.parent, Game) and isinstance(
self.parent.terminal, Terminal
): # pragma: no cover
clear_eol = self.parent.terminal.clear_eol
# Now if the viewport is greater or equal to the board size, well we just need
# a regular display()
Expand Down Expand Up @@ -511,7 +515,11 @@ def display(self):
# print("\x1b[0m")
# # eod
clear_eol = "\x1b[K"
if isinstance(self.parent, Game) and isinstance(self.parent.terminal, Terminal):
# This statement doesn't registered as tested but it is. In tests/test_board.py
# in test_partial_display.
if isinstance(self.parent, Game) and isinstance(
self.parent.terminal
): # pragma: no cover
clear_eol = self.parent.terminal.clear_eol
print(
"".join(
Expand Down
9 changes: 9 additions & 0 deletions tests/test_board.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ def test_item(self):
self.board.remove_item(j)
self.assertEqual(e.error, "invalid_item")
self.assertTrue(self.board.remove_item(i))
b = pgl_engine.Board()
i = pgl_board_items.ComplexNPC()
self.assertIsNone(b.place_item(i, 5, 5))
self.assertTrue(b.remove_item(i))

def test_move_complex(self):
def _act(p):
Expand Down Expand Up @@ -321,6 +325,11 @@ def test_display_around(self):
i = pgl_board_items.ComplexNPC()
self.board.place_item(i, 2, 2)
self.assertIsNone(self.board.display_around(i, 2, 2))
b = pgl_engine.Board(parent=pgl_engine.Game())
self.assertIsInstance(b, pgl_engine.Board)
b.place_item(i, 2, 2)
self.assertIsNone(self.board.display_around(i, 2, 2))
self.assertIsNone(self.board.display())


if __name__ == "__main__":
Expand Down

0 comments on commit dc1fcbc

Please sign in to comment.