class ShortestPathTests(imvu.test.TestCase):
    def test_shortest_path_from_x_to_x_is_x(self):
        x = object()
        self.assertEqual([x], lifetime.findShortestPath(x, x))

    def test_if_no_path_then_raise_NoPathFound(self):
        x = object()
        y = object()
        self.assertRaises(lifetime.NoPathFoundError, lambda: lifetime.findShortestPath(x, y))

    def test_find_path_through_list(self):
        y = object()
        x = [y]
        self.assertEqual([x, y], lifetime.findShortestPath(x, y))

    def test_find_path_through_two_lists(self):
        z = object()
        y = [z]
        x = [y]
        self.assertEqual([x, y, z], lifetime.findShortestPath(x, z))

    def test_returns_correct_order_through_lots_of_lists(self):
        end = object()
        expected = [end]
        beginning = end
        for i in range(1, 21):
            beginning = [beginning]
            expected = [beginning] + expected
            self.assertEqual(expected, lifetime.findShortestPath(beginning, end))

    def test_find_path_through_two_lists_and_two_dicts(self):
        z = object()
        y = [z]
        x = [y]
        w = {'a': x}
        v = {'b': w}
        self.assertEqual([v, w, x, y, z], lifetime.findShortestPath(v, z))

    def test_does_not_loop_forever_if_in_a_cycle(self):
        x = []
        x.append(x)
        y = object()
        self.assertRaises(lifetime.NoPathFoundError, lambda: lifetime.findShortestPath(x, y))

    def test_actually_finds_shortest_path(self):
        z = object()
        y = [z]
        x = [y]
        w = [x, y]
        self.assertEqual([w, y, z], lifetime.findShortestPath(w, z))
        w = [y, x]
        self.assertEqual([w, y, z], lifetime.findShortestPath(w, z))

    def test_real_scenario(self):
        sp = lifetime.findShortestPath(self, lifetime)
        #pprint.pprint(sp)

    def test_looking_for_unreachable_object_is_not_too_hard(self):
        z = object()
        self.assertRaises(lifetime.NoPathFoundError, lambda: lifetime.findShortestPath(self, z))
        
    def test_looking_for_unreachable_cycle_is_not_too_hard(self):
        class C: pass
        c = C()
        d = C()
        c.c = d
        d.d = c
        self.assertRaises(lifetime.NoPathFoundError, lambda: lifetime.findShortestPath(self, c))