def test_position_adjacent(self): origin = Position(0, 0) cardinals = [Position(0,1), Position(1,0), Position(-1, 0), Position(0, -1)] self.maxDiff = None self.assertItemsEqual([p for p in origin.adjacent()], cardinals)
def test_position_shift(self): origin = Position(0, 0) diagonal_down_right = origin.shift(1, 1) self.assertTrue(origin is not diagonal_down_right) self.assertEqual(diagonal_down_right.x(), 1) self.assertEqual(diagonal_down_right.y(), 1)