~therve/storm/twisted-integration

« back to all changes in this revision

Viewing changes to tests/variables.py

  • Committer: Thomas Hervé
  • Date: 2009-02-19 11:43:53 UTC
  • mfrom: (181.1.112 storm.trunk)
  • Revision ID: thomas@canonical.com-20090219114353-kn1iujortgoulf20
Merge from trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
from datetime import datetime, date, time, timedelta
22
22
from decimal import Decimal
23
23
import cPickle as pickle
 
24
import gc
 
25
import weakref
24
26
 
25
27
from storm.exceptions import NoneError
26
28
from storm.variables import *
91
93
        variable.set(marker, from_db=True)
92
94
        self.assertEquals(variable.sets, [(marker, False), (marker, True)])
93
95
 
 
96
    def test_set_leak(self):
 
97
        """When a variable is checkpointed, the value must not leak."""
 
98
        variable = Variable()
 
99
        m = Marker()
 
100
        m_ref = weakref.ref(m)
 
101
        variable.set(m)
 
102
        variable.checkpoint()
 
103
        variable.set(LazyValue())
 
104
        del m
 
105
        gc.collect()
 
106
        self.assertIdentical(m_ref(), None)
 
107
 
94
108
    def test_get(self):
95
109
        variable = CustomVariable()
96
110
        variable.set(marker)