Fix is_connex tests
This commit is contained in:
		@@ -2,6 +2,7 @@
 | 
				
			|||||||
# SPDX-License-Identifier: GPL-3.0-or-later
 | 
					# SPDX-License-Identifier: GPL-3.0-or-later
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import unittest
 | 
					import unittest
 | 
				
			||||||
 | 
					from random import randint
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from squirrelbattle.interfaces import Map, Tile
 | 
					from squirrelbattle.interfaces import Map, Tile
 | 
				
			||||||
from squirrelbattle.mapgeneration import randomwalk, broguelike
 | 
					from squirrelbattle.mapgeneration import randomwalk, broguelike
 | 
				
			||||||
@@ -14,13 +15,10 @@ def is_connex(grid):
 | 
				
			|||||||
    queue = Map.neighbourhood(grid, y, x)
 | 
					    queue = Map.neighbourhood(grid, y, x)
 | 
				
			||||||
    while queue != []:
 | 
					    while queue != []:
 | 
				
			||||||
        y, x = queue.pop()
 | 
					        y, x = queue.pop()
 | 
				
			||||||
        if m.tiles[y][x].can_walk():
 | 
					        if grid[y][x].can_walk():
 | 
				
			||||||
            m.tiles[y][x] = Tile.WALL
 | 
					            grid[y][x] = Tile.WALL
 | 
				
			||||||
            queue += Map.neighbourhood(grid, y, x)
 | 
					            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):
 | 
					class TestRandomWalk(unittest.TestCase):
 | 
				
			||||||
    def setUp(self) -> None:
 | 
					    def setUp(self) -> None:
 | 
				
			||||||
@@ -47,4 +45,4 @@ class TestBroguelike(unittest.TestCase):
 | 
				
			|||||||
    
 | 
					    
 | 
				
			||||||
    def test_connexity(self) -> None:
 | 
					    def test_connexity(self) -> None:
 | 
				
			||||||
        m = self.generator.run()
 | 
					        m = self.generator.run()
 | 
				
			||||||
        self.assertTrue(is_connex(m))
 | 
					        self.assertTrue(is_connex(m.tiles))
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user