Esempio n. 1
0
 def test_separation_of_init_and_enter(self):
     a = object()
     t = TrackRCFor(a)
     c = a
     with t:
         del c
         del a
     t.assertDelta(-2)
Esempio n. 2
0
 def test_nesting_by_using_pre_instantiated(self):
     a = "Another Python string, given to name \"a\""
     inner = TrackRCFor(a)
     # "outer" will see "a" decrefed twice, first by the del statement, then
     # by deleting "inner" (which itself holds a reference to a).
     with TrackRCFor(inner, a) as outer:
         with inner:
             del a
         inner.assertDelta(-1)
         del inner
     outer.assertDelta(-1, -2)