class GetNeighboursTests(unittest.TestCase): def setUp(self): self.w = 6 self.h = 6 self.grid = Grid(self.w, self.h, []) def test_get_corner_neighbours(self): result = set([l.coords for l in self.grid.get_neighbours(0, 0)]) expect = {(1, 0), (0, 1), (1, 1)} self.assertEqual(expect, result) def test_get_far_corner_neighbours(self): result = set([l.coords for l in self.grid.get_neighbours(5, 5)]) expect = {(4, 4), (5, 4), (4, 5)} self.assertEqual(expect, result) def test_get_middle_neighbours(self): result = set([l.coords for l in self.grid.get_neighbours(3, 3)]) expect = {(2, 2), (2, 3), (2, 4), (3, 2), (3, 4), (4, 2), (4, 3), (4, 4)} self.assertEqual(expect, result)
def setUp(self): self.w = 6 self.h = 6 self.grid = Grid(self.w, self.h, [])