From a390f4f5e9149273409594d3bb220ec9fa28764b Mon Sep 17 00:00:00 2001 From: Charles Peyrat Date: Fri, 8 Jan 2021 16:21:16 +0100 Subject: [PATCH] Fix is_connex tests --- squirrelbattle/tests/mapgeneration_test.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/squirrelbattle/tests/mapgeneration_test.py b/squirrelbattle/tests/mapgeneration_test.py index f546669..85d1722 100644 --- a/squirrelbattle/tests/mapgeneration_test.py +++ b/squirrelbattle/tests/mapgeneration_test.py @@ -2,6 +2,7 @@ # SPDX-License-Identifier: GPL-3.0-or-later import unittest +from random import randint from squirrelbattle.interfaces import Map, Tile from squirrelbattle.mapgeneration import randomwalk, broguelike @@ -14,13 +15,10 @@ def is_connex(grid): queue = Map.neighbourhood(grid, y, x) while queue != []: y, x = queue.pop() - if m.tiles[y][x].can_walk(): - m.tiles[y][x] = Tile.WALL + if grid[y][x].can_walk(): + grid[y][x] = Tile.WALL queue += Map.neighbourhood(grid, y, x) - return not(any([any([t.can_walk() for t in l]) for l in m.tiles])) - - - + return not(any([any([t.can_walk() for t in l]) for l in grid])) class TestRandomWalk(unittest.TestCase): def setUp(self) -> None: @@ -47,4 +45,4 @@ class TestBroguelike(unittest.TestCase): def test_connexity(self) -> None: m = self.generator.run() - self.assertTrue(is_connex(m)) + self.assertTrue(is_connex(m.tiles))