From 895abe88ad3ec947a9b6a0911f650ab774135fa9 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Fri, 11 Dec 2020 19:14:25 +0100 Subject: [PATCH] Ensure that the neighboorhood is walkable in movement tests --- squirrelbattle/tests/game_test.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/squirrelbattle/tests/game_test.py b/squirrelbattle/tests/game_test.py index bc3ce12..8203299 100644 --- a/squirrelbattle/tests/game_test.py +++ b/squirrelbattle/tests/game_test.py @@ -12,6 +12,7 @@ from ..entities.items import Bomb, Heart, Sword from ..entities.player import Player from ..enums import DisplayActions from ..game import Game, KeyValues, GameMode +from ..interfaces import Tile from ..menus import MainMenuValues from ..resources import ResourceManager from ..settings import Settings @@ -204,6 +205,12 @@ class TestGame(unittest.TestCase): self.game.map.remove_entity(entity) y, x = self.game.player.y, self.game.player.x + + # Ensure that the neighborhood is walkable + for dx in [-1, 0, 1]: + for dy in [-1, 0, 1]: + self.game.map.tiles[y + dy][x + dx] = Tile.FLOOR + self.game.handle_key_pressed(KeyValues.DOWN) new_y, new_x = self.game.player.y, self.game.player.x self.assertEqual(new_y, y + 1)