コード例 #1
0
    def test_inheritable_local_property(self):
        self.sc.setLocalProperty("a", "hi")
        expected = []

        def get_inner_local_prop():
            expected.append(self.sc.getLocalProperty("b"))

        def get_outer_local_prop():
            expected.append(self.sc.getLocalProperty("a"))
            self.sc.setLocalProperty("b", "hello")
            t2 = InheritableThread(target=get_inner_local_prop)
            t2.start()
            t2.join()

        t1 = InheritableThread(target=get_outer_local_prop)
        t1.start()
        t1.join()

        self.assertEqual(self.sc.getLocalProperty("b"), None)
        self.assertEqual(expected, ["hi", "hello"])
コード例 #2
0
 def get_outer_local_prop():
     expected.append(self.sc.getLocalProperty("a"))
     self.sc.setLocalProperty("b", "hello")
     t2 = InheritableThread(target=get_inner_local_prop)
     t2.start()
     t2.join()