示例#1
0
 def test_all_grid_neighbours(self):
     grid = boggle.make_grid(2, 2)
     neighbours = boggle.all_grid_neighbours(grid)
     self.assertEqual(len(neighbours), len(grid))
     for pos in grid:
         others = list(grid)  #Crea lista con las claves del dicionario
         others.remove(pos)
         self.assertListEqual(sorted(neighbours[pos]), sorted(others))
示例#2
0
 def test_all_grid_neighbours(self):
     grid = boggle.make_grid(2, 2)
     neighbours = boggle.all_grid_neighbours(grid)
     self.assertEqual(len(neighbours), len(grid))
     for pos in grid:
         others = list(grid)
         others.remove(pos)
         self.assertListEqual(sorted(neighbours[pos]), sorted(others))
def test_all_grid_neighbours(self):
    grid = boggle.make_grid(2, 2)
    neighbours = boggle.all_grid_neighbours(grid)
    self.assertEquals(len(neighbours), len(grid))
    for pos in grid:
        others = list(grid)  # creates a new list from the dictionary's keys
        others.remove(pos)
        self.assertListEqual(sorted(neighbours[pos]), sorted(others))
示例#4
0
 def test_all_grid_neighbours(self):
     # ensure all grid positions have neighbours
     grid = boggle.make_grid(2, 2)
     neighbours = boggle.all_grid_neighbours(grid)
     self.assertEqual(len(neighbours), len(grid))
     for pos in grid:
         others = list(grid)  #creates list from dictionarie's keys
         others.remove(pos)
         self.assertListEqual(sorted(neighbours[pos]), sorted(others))
 def test_all_grid_neighbours(self):
     grid = boggle.make_grid(2, 2)
     neighbours = boggle.all_grid_neighbours(grid)
     self.assertEquals(len(neighbours), len(grid))
     others = []
     for pos in grid:
         others[:] = grid
         others.remove(pos)
         self.assertListEqual(sorted(neighbours[pos]), sorted(others))
 def test_all_grid_neighbours(self):
     """
     Ensure that all of the grid positions have neighbours
     """
     grid = boggle.make_grid(2, 2)
     neighbours = boggle.all_grid_neighbours(grid)
     self.assertEqual(len(neighbours), len(grid))
     for pos in grid:
         others = list(grid)  #creates a new list from the dictionary's keys
         others.remove(pos)
示例#7
0
 def test_all_grid_neighbours(self):
     # Ensure that all of the grid positions have neighbors
     grid = boggle.make_grid(2, 2)
     neighbors = boggle.all_grid_neighbours(grid)
     self.assertEqual(len(neighbors), len(grid))
     for pos in grid:
         # Creates a new list from the dictionary's keys
         others = list(grid)
         others.remove(pos)
         self.assertListEqual(sorted(neighbours[pos]), sorted(others))
示例#8
0
 def test_all_grid_neighbours(self):
     """
     ensure that all grid positions have neighbours
     """
     grid = boggle.make_grid(2, 2)
     neighbours = boggle.all_grid_neighbours(grid)
     self.assertEqual(len(neighbours), len(grid))
     for pos in grid:
         others = list(grid)  #creates new list
         others.remove(pos)
         self.assertEqual(sorted(neighbours[pos]), sorted(others))
示例#9
0
 def test_all_grid_neighbours(self):
     #ensure all grid positions have neighbours
     
     grid = boggle.make_grid(2, 2)
     neighbours = boggle.all_grid_neighbours(grid) #get all neighbours 4 grid.
                              #is a dictionary where key is position and value is list of neighbouring positions
     self.assertEqual(len(neighbours), len(grid)) #assert correct length of neighbours dictionary
     for pos in grid:      #for loop iterates through positions in grid. for each pos neigh are other 3 positions
         others = list(grid) #creates new list from the dictionaries keys. this is full list
         others.remove(pos) #minus position in question
         self.assertListEqual(sorted(neighbours[pos]), sorted(others)) #asserts pos neigh are pos being checked
示例#10
0
 def test_all_grid_neighbours(self):
     """
     ENSURE THAT ALL THE GRID POSITIONS HAVE NEIGHBOURS
     """
     grid = boggle.make_grid(2, 2)
     neighbours = boggle.all_grid_neighbours(grid)
     self.assertEqual(len(neighbours), len(grid))
     for pos in grid:
         others = list(grid)  # CREATES A NEW LIST FROM DICTIONARY'S KEYS
         others.remove(pos)
         self.assertListEqual(sorted(neighbours[pos]), sorted(others))
示例#11
0
 def test_all_grid_neighbours(self):
     """
     Ensure that all of the grid positions have neighbours
     """
     grid = boggle.make_grid(2, 2)
     neighbours = boggle.all_grid_neighbours(grid)
     self.assertEqual(len(neighbours), len(grid))
     for pos in grid:
         others = list(grid) # Creates a new list from the dictionary's keys
         others.remove(pos) # Removes the position in question
         # Asserts that the positions are the neighbours of the position being checked
         self.assertListEqual(sorted(neighbours[pos]), sorted(others))
示例#12
0
 def test_all_grid_neighbours(self):
     """
     Ensure That All Of The Grid Positions Have Neighbours
     """
     grid = boggle.make_grid(2, 2)
     neighbours = boggle.all_grid_neighbours(grid)
     self.assertEqual(len(neighbours), len(grid))
     for pos in grid:
         others = list(
             grid)  # Creates A New List From The Dictionary's Keys
         others.remove(pos)
         self.assertListEqual(sorted(neighbours[pos]), sorted(others))
示例#13
0
 def test_all_grid_neighbours(self):
     """
     Test case to verify all grid positions have neighbours
     """
     grid = boggle.make_grid(2, 2)
     neighbours = boggle.all_grid_neighbours(grid)
     self.assertEqual(len(grid), len(neighbours))
     for position in grid:
         adjacents = list(grid)
         # Remove the current grid position to leave only the adjacent positions
         adjacents.remove(position)
         self.assertListEqual(sorted(neighbours[position]),
                              sorted(adjacents))
示例#14
0
 def test_all_grid_neighbours(self):
     """
     Ensure that all of the grid positions have neighbours
     """
     grid = boggle.make_grid(2, 2)
     neighbours = boggle.all_grid_neighbours(grid)
     self.assertEqual(len(neighbours), len(grid))  # ???????
     for pos in grid:  # ex. [0, 0]
         others = list(
             grid)  # creates a new list from the dictionary's keys
         # [[0, 0], [0, 1], [1, 0], [1, 1]]
         others.remove(pos)  # minus questioning position [0,0]
         self.assertListEqual(sorted(neighbours[pos]), sorted(others))
示例#15
0
 def test_all_the_grid_neighbours(self):
     """
     Ensure that all of the grid positions have neighbours
     """
     grid = boggle.make_grid(2, 2)
     neighbours = boggle.all_grid_neighbours(grid)
     self.assertEqual(len(neighbours), len(grid))
     for pos in grid:
         others = list(grid)  # create a new list from the dictionary's keys
         # for each position the neighbors are the other three positions on the grid so we create the
         #others list which is a full grid minus (-) the positioning question
         others.remove(pos)
         self.assertListEqual(sorted(neighbours[pos]), sorted(others))
示例#16
0
    def test_all_grid_neighbours(self):
        """
        Ensure that all of the grid positions have neighbours
        """

        #The self.assertEqual here tests for equality

        grid = boggle.make_grid(2, 2)
        neighbours = boggle.all_grid_neighbours(grid)
        self.assertEqual(len(neighbours), len(grid))
        for position in grid:
            others = list(grid)  #creates a new list from the dictionares keys
            others.remove(position)
            self.assertListEqual(sorted(neighbours[position]), sorted(others))
示例#17
0
 def test_all_grid_neighbours(self):
     """
     Ensure that all of the grid positions have neighbours
     """
     grid = boggle.make_grid(2, 2)
     neighbours = boggle.all_grid_neighbours(
         grid)  # This is a dictionary where the key is a position
     self.assertEqual(
         len(neighbours), len(grid)
     )  # just like with the grid itself but the value is a list of neighboring positions. This next line can assert the correct length of the neighbors dictionary
     for pos in grid:
         others = list(grid)  # create a new list from the dictionary's keys
         others.remove(pos)
         self.assertListEqual(sorted(neighbours[pos]), sorted(others))
示例#18
0
 def test_all_grid_neighbours(self):
     '''
     Ensure that all of the grid positions have neighbours (this accounts for the edge and corner pieces)
     In (2,2) grid, every position touches every other position, so the neighbours of any position are other three positions in the grid
     '''
     grid = boggle.make_grid(2, 2)
     # We get all the neighbours for the grid - dictionary where key is the position but value is list of neighbouring positions
     neighbours = boggle.all_grid_neighbours(grid)
     # Asserts the length of the neighbours dictionary, which should be equal to the grid length
     self.assertEqual(len(neighbours), len(grid))
     # The for loop iterates through the other positions - we create the others list, which is the full grid minus the current position
     for pos in grid:
         others = list(grid)
         others.remove(pos)
         self.assertListEqual(sorted(neighbours[pos]), sorted(others))
示例#19
0
    def test_all_grid_neighbours(self):

        #ensure that all grid positions have neighbours

        grid = boggle.make_grid(2, 2)
        neighbours = boggle.all_grid_neighbours(grid)
        self.assertEqual(
            len(neighbours),
            len(grid))  #assert correct length of neighbours dictionary
        for pos in grid:  #for loop will iterate through positions in the grid
            others = list(
                grid)  #creates a new list from dictionarys keys. full list
            others.remove(pos)  #minus position in question
            self.assertListEqual(
                sorted(neighbours[pos]),
                sorted(others))  # asserts position of neighbours is
示例#20
0
    def test_all_grid_neighbours(self):
        """
        Ensure that all of the grid positions have neighbours. 
        Creation of 2 x 2 grid allows for all grid spaces to be captured
        within the overall 3 x 3 grid. Upto x4 of (2x2) grids in overall
        3 x 3 grid
        """

        grid = boggle.make_grid(2, 2)
        neighbours = boggle.all_grid_neighbours(grid)
        self.assertEqual(len(neighbours), len(grid))
        for pos in grid:
            others = list(
                grid)  # Creates a new list from the dictionaries keys
            others.remove(pos)
            self.assertListEqual(sorted(neighbours[pos]), sorted(
                others))  # Asserts the positions of neighbours being checked.
示例#21
0
 def test_all_grid_neighbours(self):
     """
     Ensure that all of the grid have neighbours
     """
     grid = boggle.make_grid(2, 2)
     neighbours = boggle.all_grid_neighbours(
         grid)  #get all neighbours of a grid
     self.assertEqual(
         len(neighbours),
         len(grid))  #assert the correct length of neighbours dict
     for pos in grid:  #iterate through the positions in the grid for each position
         others = list(grid)  # create a new list from the dictionary's keys
         others.remove(
             pos
         )  # thus we create the full grid but remove the pos to show the neighbours only
         self.assertListEqual(
             sorted(neighbours[pos]), sorted(others)
         )  #the positions of the neighbours are the positions being checked
示例#22
0
 def test_all_grid_neighbours(self):
     """
     Ensure that all of the grid positions have neighbours
     """
     grid = boggle.make_grid(
         2, 2
     )  #Grid variable, makes a 2 x 2 grid (Neighbours of any position are the other two positions in the grid)
     neighbours = boggle.all_grid_neighbours(grid)  #Creates a dictionary
     self.assertEqual(len(neighbours), len(
         grid))  #Asserts the correct length of the neighbours dictionary.
     for pos in grid:  #For loop iterates through the grid.
         others = list(
             grid
         )  #Creates a list which is the full grid minus the position in question.
         others.remove(
             pos)  #Removes the position in question from the others list.
         self.assertListEqual(
             sorted(neighbours[pos]), sorted(others)
         )  #Asserts that the positions are the neighbours of the position being checked.
示例#23
0
 def test_all_grid_neighbours(self):
     grid = boggle.make_grid(2, 2)
     neighbours = boggle.all_grid_neighbours(grid)
     self.assertEqual(len(neighbours), len(grid))