Пример #1
0
 def test_depth_2(self):
     """
     Check cases in which the original object depends on another, which
     depends on another.
     """
     o1 = Identity()
     o2 = Identity()
     o3 = object()
     o1.depends_on = ["o2"]
     o2.depends_on = ["o3"]
     o1.o2 = o2
     o2.o3 = o3
     self.assertEqual(get_owners(o1), [o1, o2, o3])
Пример #2
0
    def test_depth_1(self):
        """
        Check cases in which the original object depends on 1 or more others.
        """
        o1 = Identity()
        o2 = Identity()
        o1.o2 = o2
        o1.depends_on = ["o2"]
        self.assertEqual(get_owners(o1), [o1, o2])

        o3 = object()
        o1.depends_on = ["o3", "o2"]
        o1.o3 = o3
        self.assertEqual(get_owners(o1), [o1, o3, o2])
Пример #3
0
 def test_circular3(self):
     """
     Verify that a circular dependency among 3 objects is detected.
     """
     o1 = Identity()
     o2 = Identity()
     o3 = Identity()
     o1.depends_on = ["o2"]
     o2.depends_on = ["o3"]
     o3.depends_on = ["o1"]
     o1.o2 = o2
     o2.o3 = o3
     o3.o1 = o1
     with self.assertRaises(RuntimeError):
         get_owners(o1)