Example #1
0
class TestFifoList(unittest.TestCase):
    def setUp(self):
        self.f = FifoList()
        self.f.append(1)
        self.f.append(2)
        self.f.append(3)

    def test_pop_returns_first_element(self):
        self.assertEquals(self.f.pop(), 1)
        self.assertEquals(len(self.f), 2)
Example #2
0
class TestFifoList(unittest.TestCase):
    def setUp(self):
        self.f = FifoList()
        self.f.append(1)
        self.f.append(2)
        self.f.append(3)

    def test_pop_returns_first_element(self):
        self.assertEqual(self.f.pop(), 1)
        self.assertEqual(len(self.f), 2)

    def test_sorted_fifo(self):
        self.assertTrue(sorted_equals_pop(self.f))
Example #3
0
def breadth_first(problem, graph_search=False):
    '''
    Breadth first search.

    If graph_search=True, will avoid exploring repeated states.
    Requires: SearchProblem.actions, SearchProblem.result, and
    SearchProblem.is_goal.
    '''
    return _search(problem, FifoList(), graph_search=graph_search)
Example #4
0
class TestFifoList(unittest.TestCase):
    def setUp(self):
        self.f = FifoList()
        self.f.append(1)
        self.f.append(2)
        self.f.append(3)

    def test_pop_returns_first_element(self):
        self.assertEquals(self.f.pop(), 1)

    def test_pop_with_index_works(self):
        self.assertEquals(self.f.pop(1), 2)
Example #5
0
 def setUp(self):
     self.f = FifoList()
     self.f.append(1)
     self.f.append(2)
     self.f.append(3)