Exemplo n.º 1
0
    def testUpdate_12_Atomic_02(self):

        p = TreeDict()
        p.a   = 1
        p.c   = 2

        p2 = TreeDict()
        p2.a.x = 3
        p2.c   = 4

        p_before = p.copy()

        self.assert_(p == p_before)

        self.checkUpdateBadStructure(p, p2)

        self.assert_(p == p_before)
Exemplo n.º 2
0
    def testDangling_14_CorrectParentingSetAtFixing_03(self):

        p = TreeDict()
        v = unique_object()

        p.b = p.c
        p.a = p.b

        # Set c and fix p.b
        p.c = 1
        p.b = 1
        p.a.x = 1

        # Now b should be
        self.assert_(p.a.branchName() == 'a')
Exemplo n.º 3
0
    def testPicklingWithIteratorReferencing(self):

        p = TreeDict()

        p.a = 1
        p.b = 2
        p.c = 3

        it = p.iteritems()

        p2 = cPickle.loads(cPickle.dumps(p, protocol=2))

        self.assert_(p == p2)

        self.assertRaises(RuntimeError, lambda: p.set('d', 4))
        p2.d = 4
    def testIterators_12_Deletion(self):
        p = TreeDict()

        p.a = 1
        p.b = 2
        p.c = 3
        p.d = 4 
        p.e = 5

        it = p.iterkeys()
        
        self.assertRaises(RuntimeError, lambda: p.pop('a'))
        it.next()
        self.assertRaises(RuntimeError, lambda: p.pop('a'))
        
        del it

        p.pop('a')
Exemplo n.º 5
0
    def testDangling_12_ForwardAssingmentSetCorrectlyWithReference(self):

        p = TreeDict()
        v = unique_object()

        b = p.a = p.c
        p.c = v

        self.assert_(p.a is not v)
        self.assert_(p.a.isDangling() )

        p.a.v = v

        self.assert_(not p.a.isDangling() )
        self.assert_(p.a.v is v)
        self.assert_(b.v is v)
        self.assert_(b is p.a)
        self.assert_(p.c is v)
Exemplo n.º 6
0
    def testSet_30_ValueFrozen_01(self):
        p = TreeDict(a = 1, b = 2)
        p.freeze(values_only = True)

        p.c = 3