From: Daniel Berger Date: 2007-12-22T10:21:08+09:00 Subject: Re: First stab at a weakref test suite On Dec 21, 6:50 am, Charles Oliver Nutter wrote: > Eric Hodel wrote: > > On Dec 20, 2007, at 21:45 PM, Daniel Berger wrote: > >> I follow the same pattern in the tests, but it doesn't raise the > >> expected error. Any ideas? > > > Since the GC is conservative, references may exist longer than you > > expect because the item that should be collected is still referenced > > from the stack. I don't know of an easy way around this. > > This is probably the largest reason why a weakref suite will be a little > tricky. My best recommendation would be to loop calling GC.start until > the reference gets collected; perhaps with an upper count... "if we > reach 1000 iterations and it's not collected, it isn't working". I took a look at the Python weakref test suite. I quickly realized that it appeared to be a richer interface. Maybe that's part of the problem - the interface we have isn't testable. Take a look here: http://www.python.org/doc/2.4/lib/module-weakref.html Then again, maybe I'm way off base. Anyway, I think we should at least take a look at it and see if we want to steal any ideas from it. The corresponding test file is test_weakref.py, btw. Regards, Dan