Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(20)  |  Call(18)  |  Derive(0)  |  Import(2)
An implementation of weak references that works for bound methods. 

src/e/n/envisage-4.4.0/envisage/tests/safeweakref_test_case.py   envisage(Download)
 
# Enthought library imports.
from envisage.safeweakref import ref
from traits.api import HasTraits
from traits.testing.unittest_tools import unittest
 
        # Get a weak reference to a bound method.
        r = ref(f.method)
        self.assertNotEqual(None, r())
 
        # Create a weak reference to the bound method and make sure that
        # exactly one item has been added to the cache.
        r = ref(f.method)
        self.assertEqual(len_cache + 1, len(cache))
 
 
        # Make sure that two references to the same method compare as equal.
        r1 = ref(f.method)
        r2 = ref(f.method)
        self.assertEqual(r1, r2)

src/e/n/envisage-HEAD/envisage/tests/safeweakref_test_case.py   envisage(Download)
 
# Enthought library imports.
from envisage.safeweakref import ref
from traits.api import HasTraits
from traits.testing.unittest_tools import unittest
 
        # Get a weak reference to a bound method.
        r = ref(f.method)
        self.assertNotEqual(None, r())
 
        # Create a weak reference to the bound method and make sure that
        # exactly one item has been added to the cache.
        r = ref(f.method)
        self.assertEqual(len_cache + 1, len(cache))
 
 
        # Make sure that two references to the same method compare as equal.
        r1 = ref(f.method)
        r2 = ref(f.method)
        self.assertEqual(r1, r2)