def weakrefs():
    if verbose: print "Testing weak references..."
    import weakref
    class C(object):
        pass
    c = C()
    r = weakref.ref(c)
    verify(r() is c)
    del c
    extra_collect()
    verify(r() is None)
    del r
    class NoWeak(object):
        __slots__ = ['foo']
    no = NoWeak()
    try:
        weakref.ref(no)
    except __HOLE__, msg:
        verify(str(msg).find("weak reference") >= 0)
    else:
        # XXX: Jython allows a weakref here
        if not is_jython:
            verify(0, "weakref.ref(no) should be illegal")
    class Weak(object):
        __slots__ = ['foo', '__weakref__']
    yes = Weak()
    r = weakref.ref(yes)
    verify(r() is yes)
    del yes
    extra_collect()
    verify(r() is None)
    del r
dataset/ETHPy150Open azoft-dev-team/imagrium/env/Lib/test/test_descr.py/weakrefs